1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-22 04:43:00 +00:00

ProjectCommand, ServiceCommand aux classes

This commit is contained in:
Jörn-Michael Miehe 2020-08-13 11:32:54 +02:00
parent d67b04897f
commit 082c5f220c
2 changed files with 33 additions and 12 deletions

View file

@ -23,3 +23,33 @@ class SubCommand:
def run(self, config, args): def run(self, config, args):
"""actually run command with this dir's config and parsed CLI args""" """actually run command with this dir's config and parsed CLI args"""
pass 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"
)

View file

@ -2,32 +2,23 @@
import logging import logging
# local # local
from ._subcommand import SubCommand from ._subcommand import ServiceCommand
from .utils.dockercommand import DockerCommand from .utils.dockercommand import DockerCommand
class LogsCommand(SubCommand): class LogsCommand(ServiceCommand):
def __init__(self): def __init__(self):
super().__init__( super().__init__(
'logs', 'logs',
description="Show logs of a project or service(s) of a project" description="Show logs of a project or service(s) of a project"
) )
# -f switch: Follow logs
self._sub_parser.add_argument( self._sub_parser.add_argument(
'-f', '--follow', action='store_true', '-f', '--follow', action='store_true',
help="output appended data as log grows" 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): def run(self, config, args):
project_name = args.project project_name = args.project
project_marker = config['markers:project'] project_marker = config['markers:project']