6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-12 14:17:46 +00:00

Add `-U/--unset option to config save`

This commit is contained in:
Régis Behmo 2019-07-08 06:29:24 +08:00
parent d7477ba348
commit ce8a0315cb
3 changed files with 19 additions and 13 deletions

View File

@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥".
## Latest
- [Improvement] Add ``-U/--unset`` option to ``config save``
- [Bugfix] Fix insecure static asset loading when web proxy is enabled
- [Improvement] Rename ``SECRET_KEY`` configuration parameter to ``OPENEDX_SECRET_KEY``
- [Improvement] Add support for SSL and TLS in external SMTP server (#231)

View File

@ -20,11 +20,27 @@ def config_command():
@click.command(help="Create and save configuration interactively")
@opts.root
@click.option("-i", "--interactive", is_flag=True, help="Run interactively")
@opts.key_value
def save(root, interactive, set_):
@click.option(
"-s",
"--set",
"set_",
type=opts.YamlParamType(),
multiple=True,
metavar="KEY=VAL",
help="Set a configuration value (can be used multiple times)",
)
@click.option(
"-U",
"--unset",
multiple=True,
help="Remove a configuration value (can be used multiple times)",
)
def save(root, interactive, set_, unset):
config, defaults = interactive_config.load_all(root, interactive=interactive)
if set_:
tutor_config.merge(config, dict(set_), force=True)
for key in unset:
config.pop(key, None)
tutor_config.save(root, config)
tutor_config.merge(config, defaults)
env.save(root, config)

View File

@ -40,14 +40,3 @@ class YamlParamType(click.ParamType):
except ValueError:
self.fail("'{}' is not of the form 'key=value'.".format(value), param, ctx)
return k, serialize.parse_value(v)
key_value = click.option(
"-s",
"--set",
"set_",
type=YamlParamType(),
multiple=True,
metavar="KEY=VAL",
help="Set a configuration value (can be used multiple times)",
)