diff --git a/tutor/commands/config.py b/tutor/commands/config.py index cc7eb13..76bf2f2 100644 --- a/tutor/commands/config.py +++ b/tutor/commands/config.py @@ -37,7 +37,7 @@ class YamlParamType(click.ParamType): @click.option( "-s", "--set", - "set_", + "set_vars", type=YamlParamType(), multiple=True, metavar="KEY=VAL", @@ -46,17 +46,18 @@ class YamlParamType(click.ParamType): @click.option( "-U", "--unset", + "unset_vars", multiple=True, help="Remove a configuration value (can be used multiple times)", ) @click.pass_obj -def save(context, interactive, set_, unset): +def save(context, interactive, set_vars, unset_vars): config, defaults = interactive_config.load_all( context.root, interactive=interactive ) - if set_: - tutor_config.merge(config, dict(set_), force=True) - for key in unset: + if set_vars: + tutor_config.merge(config, dict(set_vars), force=True) + for key in unset_vars: config.pop(key, None) tutor_config.save_config_file(context.root, config) tutor_config.merge(config, defaults) diff --git a/tutor/commands/local.py b/tutor/commands/local.py index c9648e1..2fc1e81 100644 --- a/tutor/commands/local.py +++ b/tutor/commands/local.py @@ -3,13 +3,12 @@ from textwrap import indent import click -from . import compose -from .context import Context from .. import config as tutor_config from .. import env as tutor_env -from .. import fmt -from .. import interactive as interactive_config -from .. import utils +from .. import fmt, utils +from . import compose +from .config import save as config_save_command +from .context import Context # pylint: disable=too-few-public-methods @@ -53,9 +52,7 @@ def quickstart(context, non_interactive, pullimages_): ) click.echo(fmt.title("Interactive platform configuration")) - config = interactive_config.update(context.root, interactive=(not non_interactive)) - click.echo(fmt.title("Updating the current environment")) - tutor_env.save(context.root, config) + config_save_command.callback(interactive=(not non_interactive), set_vars=[], unset_vars=[]) click.echo(fmt.title("Stopping any existing platform")) compose.stop.callback([]) click.echo(fmt.title("HTTPS certificates generation")) @@ -68,6 +65,7 @@ def quickstart(context, non_interactive, pullimages_): click.echo(fmt.title("Database creation and migrations")) compose.init.callback(limit=None) + config = tutor_config.load(context.root) fmt.echo_info( """The Open edX platform is now running in detached mode Your Open edX platform is ready and can be accessed at the following urls: diff --git a/tutor/env.py b/tutor/env.py index 9fad254..4d5931e 100644 --- a/tutor/env.py +++ b/tutor/env.py @@ -231,7 +231,7 @@ def write_to(content, path): if isinstance(content, bytes): open_mode += "b" utils.ensure_file_directory_exists(path) - with open(path, open_mode, encoding='utf8') as of: + with open(path, open_mode, encoding="utf8") as of: of.write(content)