diff --git a/legl_dev/main.py b/legl_dev/main.py index a9f441f..be44a1f 100755 --- a/legl_dev/main.py +++ b/legl_dev/main.py @@ -309,6 +309,13 @@ def install( steps.run() +@app.command(help="Remote into a container") +def shell(environment: Optional[str] = typer.Argument(default="backend", help="Container to remote into")): + steps = Steps() + steps.add( + Command(command=f"docker compose exec {environment} bash") + ) + steps.run() @app.callback() def main(version: bool = False): diff --git a/legl_dev/tests/test_main.py b/legl_dev/tests/test_main.py index 1547dc2..845c7a1 100644 --- a/legl_dev/tests/test_main.py +++ b/legl_dev/tests/test_main.py @@ -159,3 +159,29 @@ def test_install_self_upgrade(run): ), ] run.assert_has_calls(calls) + +@mock.patch("legl_dev.command.run") +def test_remote_frontend_commands(run): + main.shell("frontend") + calls = [ + mock.call( + ["docker", "compose", "exec", "frontend", "bash"], + universal_newlines=True, + shell=False, + check=True, + ), + ] + run.assert_has_calls(calls) + +@mock.patch("legl_dev.command.run") +def test_remote_frontend_commands(run): + main.shell("frontend") + calls = [ + mock.call( + ["docker", "compose", "exec", "frontend", "bash"], + universal_newlines=True, + shell=False, + check=True, + ), + ] + run.assert_has_calls(calls) diff --git a/setup.py b/setup.py index 7705eb8..aed7fd5 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from setuptools import setup -version = "1.1.2" +version = "1.2.0" packages = ["legl_dev"]