pmb.helpers.frontend.config: add option to reset config to default (!1907)

This commit is contained in:
Niklas Cathor 2020-04-06 15:47:13 +02:00 committed by Alexey Min
parent 00a4eaf91d
commit 29a3cb2b8c
No known key found for this signature in database
GPG key ID: EBF5ECFFFEE34DED
2 changed files with 10 additions and 1 deletions

View file

@ -140,7 +140,14 @@ def config(args):
raise RuntimeError("Invalid config key: " + args.name)
cfg = pmb.config.load(args)
if args.value is not None:
if args.reset:
if args.name is None:
raise RuntimeError("config --reset requires a name to be given.")
value = pmb.config.defaults[args.name]
cfg["pmbootstrap"][args.name] = value
logging.info("Config changed to default: " + args.name + "='" + value + "'")
pmb.config.save(args, cfg)
elif args.value is not None:
cfg["pmbootstrap"][args.name] = args.value
logging.info("Config changed: " + args.name + "='" + args.value + "'")
pmb.config.save(args, cfg)