mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-12-25 18:42:59 +00:00
ProjectCommand, ServiceCommand aux classes
This commit is contained in:
parent
d67b04897f
commit
082c5f220c
2 changed files with 33 additions and 12 deletions
|
@ -23,3 +23,33 @@ class SubCommand:
|
|||
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"
|
||||
)
|
||||
|
|
|
@ -2,32 +2,23 @@
|
|||
import logging
|
||||
|
||||
# local
|
||||
from ._subcommand import SubCommand
|
||||
from ._subcommand import ServiceCommand
|
||||
from .utils.dockercommand import DockerCommand
|
||||
|
||||
|
||||
class LogsCommand(SubCommand):
|
||||
class LogsCommand(ServiceCommand):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
'logs',
|
||||
description="Show logs of a project or service(s) of a project"
|
||||
)
|
||||
|
||||
# -f switch: Follow logs
|
||||
self._sub_parser.add_argument(
|
||||
'-f', '--follow', action='store_true',
|
||||
help="output appended data as log grows"
|
||||
)
|
||||
|
||||
self._sub_parser.add_argument(
|
||||
'project', type=str,
|
||||
help="select a project in this instance"
|
||||
)
|
||||
|
||||
self._sub_parser.add_argument(
|
||||
'services', metavar='service', nargs='*', type=str,
|
||||
help="select service(s) in a project"
|
||||
)
|
||||
|
||||
def run(self, config, args):
|
||||
project_name = args.project
|
||||
project_marker = config['markers:project']
|
||||
|
|
Loading…
Reference in a new issue