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/cmd.py
2020-08-19 17:21:38 +02:00

40 lines
1.1 KiB
Python

# system
import logging
# local
from ..subcommand import ProjectCommand
class CmdCommand(ProjectCommand):
"""kiwi cmd"""
def __init__(self):
super().__init__(
'cmd', num_projects=1,
action="Running docker-compose in",
description="Run raw docker-compose command in a project"
)
# command for docker-compose
self._sub_parser.add_argument(
'compose_cmd', metavar='cmd', type=str,
help="command for 'docker-compose'"
)
# arguments for docker-compose command
self._sub_parser.add_argument(
'compose_args', metavar='arg', nargs='*', type=str,
help="arguments for 'docker-compose' commands"
)
def _run_projects(self, runner, args, projects):
if args.unknowns:
args.compose_args = [*args.compose_args, *args.unknowns]
args.unknowns = []
logging.debug(f"Updated args: {args}")
# run with split compose_cmd argument
projects[0].compose_run([args.compose_cmd, *args.compose_args])
return True