From 4f9bb7d752d5451cb68adac6bc65cb25e64b98ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Sun, 5 May 2019 12:22:14 +0200 Subject: [PATCH] Add `local exec` command --- CHANGELOG.md | 1 + tutor/local.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1eb231..3530b03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Latest +- [Improvement] Add `local exec` command for running commands inside existing containers - [Bugfix] Fix triple display of courses in LMS search (upstream patch, #189) ## 3.3.8 (2019-04-28) diff --git a/tutor/local.py b/tutor/local.py index 0e8d879..35e95a3 100644 --- a/tutor/local.py +++ b/tutor/local.py @@ -129,6 +129,22 @@ def run(root, service, command, args): docker_compose(root, config, *run_command) +@click.command( + help="Exec a command in a running container", + context_settings={"ignore_unknown_options": True}, +) +@opts.root +@click.argument("service") +@click.argument("command") +@click.argument("args", nargs=-1, required=False) +def execute(root, service, command, args): + exec_command = ["exec", service, command] + if args: + exec_command += args + config = tutor_config.load(root) + docker_compose(root, config, *exec_command) + + @click.command(help="Create databases and run database migrations") @opts.root def databases(root): @@ -353,6 +369,7 @@ local.add_command(start) local.add_command(stop) local.add_command(restart) local.add_command(run) +local.add_command(execute, name="exec") local.add_command(databases) local.add_command(https) local.add_command(logs)