pmb.helpers.frontend.config: add option to reset config to default (!1907)
This commit is contained in:
parent
00a4eaf91d
commit
29a3cb2b8c
|
@ -140,7 +140,14 @@ def config(args):
|
||||||
raise RuntimeError("Invalid config key: " + args.name)
|
raise RuntimeError("Invalid config key: " + args.name)
|
||||||
|
|
||||||
cfg = pmb.config.load(args)
|
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
|
cfg["pmbootstrap"][args.name] = args.value
|
||||||
logging.info("Config changed: " + args.name + "='" + args.value + "'")
|
logging.info("Config changed: " + args.name + "='" + args.value + "'")
|
||||||
pmb.config.save(args, cfg)
|
pmb.config.save(args, cfg)
|
||||||
|
|
|
@ -603,6 +603,8 @@ def arguments():
|
||||||
# Action: config
|
# Action: config
|
||||||
config = sub.add_parser("config",
|
config = sub.add_parser("config",
|
||||||
help="get and set pmbootstrap options")
|
help="get and set pmbootstrap options")
|
||||||
|
config.add_argument("-r", "--reset", action="store_true",
|
||||||
|
help="Reset config options with the given name to it's default.")
|
||||||
config.add_argument("name", nargs="?", help="variable name, one of: " +
|
config.add_argument("name", nargs="?", help="variable name, one of: " +
|
||||||
", ".join(sorted(pmb.config.config_keys)),
|
", ".join(sorted(pmb.config.config_keys)),
|
||||||
choices=pmb.config.config_keys, metavar="name")
|
choices=pmb.config.config_keys, metavar="name")
|
||||||
|
|
Loading…
Reference in New Issue