2021-11-13 02:27:27 +00:00
|
|
|
from typing import Tuple
|
|
|
|
|
|
|
|
import click
|
|
|
|
|
2021-12-02 16:19:14 +00:00
|
|
|
from .cmd import KiwiCommandType, KiwiCommand
|
2021-11-13 02:27:27 +00:00
|
|
|
from .decorators import kiwi_command
|
|
|
|
from ..executable import COMPOSE_EXE
|
2021-12-02 16:08:14 +00:00
|
|
|
from ..instance import Instance
|
|
|
|
from ..project import Project
|
2021-11-13 02:27:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
@click.argument(
|
|
|
|
"compose_args",
|
|
|
|
metavar="[ARG]...",
|
|
|
|
nargs=-1,
|
|
|
|
)
|
|
|
|
@click.argument(
|
|
|
|
"compose_cmd",
|
2021-11-17 15:23:55 +00:00
|
|
|
metavar="COMMAND",
|
2021-11-13 02:27:27 +00:00
|
|
|
)
|
|
|
|
@kiwi_command(
|
|
|
|
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
|
|
|
)
|
2021-11-17 15:23:55 +00:00
|
|
|
class CmdCommand(KiwiCommand):
|
2021-11-13 02:27:27 +00:00
|
|
|
"""Run raw docker-compose command in a project"""
|
|
|
|
|
2021-12-01 16:49:19 +00:00
|
|
|
type = KiwiCommandType.PROJECT
|
|
|
|
enabled_only = True
|
|
|
|
|
2021-11-13 02:27:27 +00:00
|
|
|
@classmethod
|
2021-11-27 17:32:51 +00:00
|
|
|
def run_for_project(cls, instance: Instance, project: Project, compose_cmd: str = None,
|
|
|
|
compose_args: Tuple[str] = None) -> None:
|
2021-12-01 16:49:19 +00:00
|
|
|
COMPOSE_EXE.run([compose_cmd, *compose_args], **project.process_kwargs)
|