2020-08-12 15:46:50 +00:00
|
|
|
# parent
|
2020-08-12 14:43:13 +00:00
|
|
|
from ..parser import Parser
|
|
|
|
|
|
|
|
|
|
|
|
class SubCommand:
|
2020-08-13 08:48:01 +00:00
|
|
|
"""represents kiwi [anything] command"""
|
|
|
|
|
|
|
|
# actual command string
|
2020-08-12 14:43:13 +00:00
|
|
|
__name = None
|
2020-08-13 08:48:01 +00:00
|
|
|
# command parser
|
2020-08-12 14:43:13 +00:00
|
|
|
_sub_parser = None
|
|
|
|
|
|
|
|
def __init__(self, name, **kwargs):
|
|
|
|
self.__name = name
|
2020-08-13 08:48:01 +00:00
|
|
|
self._sub_parser = Parser().get_subparsers().add_parser(
|
|
|
|
name,
|
|
|
|
**kwargs
|
|
|
|
)
|
2020-08-12 14:43:13 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.__name
|
|
|
|
|
|
|
|
def run(self, config, args):
|
2020-08-13 08:48:01 +00:00
|
|
|
"""actually run command with this dir's config and parsed CLI args"""
|
2020-08-12 14:43:13 +00:00
|
|
|
pass
|
2020-08-13 09:32:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ProjectCommand(SubCommand):
|
|
|
|
"""this command concerns a project in current instance"""
|
|
|
|
|
|
|
|
def __init__(self, name, **kwargs):
|
|
|
|
super().__init__(
|
|
|
|
name,
|
|
|
|
**kwargs
|
|
|
|
)
|
|
|
|
|
|
|
|
self._sub_parser.add_argument(
|
|
|
|
'project', type=str,
|
|
|
|
help="select a project in this instance"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class ServiceCommand(ProjectCommand):
|
|
|
|
"""this command concerns services in a project"""
|
|
|
|
|
|
|
|
def __init__(self, name, **kwargs):
|
|
|
|
super().__init__(
|
|
|
|
name,
|
|
|
|
**kwargs
|
|
|
|
)
|
|
|
|
|
|
|
|
self._sub_parser.add_argument(
|
|
|
|
'services', metavar='service', nargs='*', type=str,
|
|
|
|
help="select service(s) in a project"
|
|
|
|
)
|