2020-08-19 14:10:56 +00:00
|
|
|
# system
|
|
|
|
import logging
|
|
|
|
|
2020-08-13 11:00:32 +00:00
|
|
|
# local
|
|
|
|
from ._subcommand import ProjectCommand
|
|
|
|
from .utils.dockercommand import DockerCommand
|
|
|
|
|
|
|
|
|
|
|
|
class CmdCommand(ProjectCommand):
|
2020-08-13 12:26:49 +00:00
|
|
|
"""kiwi cmd"""
|
|
|
|
|
2020-08-13 11:00:32 +00:00
|
|
|
def __init__(self):
|
|
|
|
super().__init__(
|
2020-08-17 10:58:18 +00:00
|
|
|
'cmd', num_projects=1,
|
2020-08-19 14:10:56 +00:00
|
|
|
action="Running docker-compose in",
|
2020-08-13 11:00:32 +00:00
|
|
|
description="Run raw docker-compose command in a project"
|
|
|
|
)
|
|
|
|
|
2020-08-19 14:10:56 +00:00
|
|
|
# command for docker-compose
|
2020-08-13 11:00:32 +00:00
|
|
|
self._sub_parser.add_argument(
|
|
|
|
'compose_cmd', metavar='cmd', type=str,
|
2020-08-19 14:10:56 +00:00
|
|
|
help="command for 'docker-compose'"
|
2020-08-13 11:00:32 +00:00
|
|
|
)
|
|
|
|
|
2020-08-19 14:10:56 +00:00
|
|
|
# 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}")
|
2020-08-13 11:00:32 +00:00
|
|
|
|
2020-08-13 12:26:49 +00:00
|
|
|
# run with split compose_cmd argument
|
2020-08-19 14:10:56 +00:00
|
|
|
DockerCommand('docker-compose').run(projects[0], [
|
|
|
|
args.compose_cmd, *args.compose_args
|
|
|
|
])
|
2020-08-17 13:00:05 +00:00
|
|
|
|
|
|
|
return True
|