get_command member find method

This commit is contained in:
Jörn-Michael Miehe 2022-01-19 15:35:33 +01:00
parent 558726f261
commit 3862ea1901
2 changed files with 10 additions and 3 deletions

View file

@ -26,9 +26,16 @@ class KiwiCLI(click.MultiCommand):
except ImportError: except ImportError:
return return
for cmd_name in dir(cmd_module): member_name = f"{cmd_name.capitalize()}Command"
member = getattr(cmd_module, cmd_name)
if member_name in dir(cmd_module):
member = getattr(cmd_module, member_name)
if isinstance(member, click.Command): if isinstance(member, click.Command):
return member return member
else:
raise Exception("Fail class")
else:
raise Exception("Fail member name")

View file

@ -13,7 +13,7 @@ from ..project import Project
help=f"skip confirmation", help=f"skip confirmation",
) )
@kiwi_command() @kiwi_command()
class DisableCommand(KiwiCommand): class EnableCommand(KiwiCommand):
"""Enable project(s)""" """Enable project(s)"""
type = KiwiCommandType.PROJECTS type = KiwiCommandType.PROJECTS