1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-22 21:03:00 +00:00
kiwi-scp/src/kiwi/subcommands/_subcommand.py

55 lines
1.2 KiB
Python

# parent
from ..parser import Parser
class SubCommand:
"""represents kiwi [anything] command"""
# actual command string
__name = None
# command parser
_sub_parser = None
def __init__(self, name, **kwargs):
self.__name = name
self._sub_parser = Parser().get_subparsers().add_parser(
name,
**kwargs
)
def __str__(self):
return self.__name
def run(self, config, args):
"""actually run command with this dir's config and parsed CLI args"""
pass
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"
)