1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-25 14:03:00 +00:00
kiwi-scp/kiwi_scp/commands/cmd_cmd.py

35 lines
996 B
Python
Raw Normal View History

2021-11-13 02:27:27 +00:00
from typing import Tuple
import click
from .cli import KiwiCommand, KiwiCommandType
from .decorators import kiwi_command
from ..executable import COMPOSE_EXE
from ..instance import Instance, Project
@click.argument(
"compose_args",
metavar="[ARG]...",
nargs=-1,
)
@click.argument(
"compose_cmd",
metavar="COMMAND",
2021-11-13 02:27:27 +00:00
)
@kiwi_command(
cmd_type=KiwiCommandType.PROJECT,
2021-11-13 02:27:27 +00:00
short_help="Run docker-compose command",
2021-11-13 02:35:52 +00:00
# ignore arguments looking like options
# just pass everything down to docker-compose
context_settings={"ignore_unknown_options": True},
2021-11-13 02:27:27 +00:00
)
class CmdCommand(KiwiCommand):
2021-11-13 02:27:27 +00:00
"""Run raw docker-compose command in a project"""
@classmethod
def run_for_existing_project(cls, instance: Instance, project: Project, compose_cmd: str = None,
compose_args: Tuple[str] = None) -> None:
if project.project_config.enabled:
COMPOSE_EXE.run([compose_cmd, *compose_args], **project.process_kwargs)