Add output to config --set

This commit is contained in:
Tim Van Baak 2020-01-19 00:09:36 -08:00
parent 5e8a761675
commit 851f08b5f3
4 changed files with 8 additions and 6 deletions

View File

@ -83,11 +83,11 @@ def config_get(cfg, pathspec):
cfg = cfg.get(spec)
print(json.dumps(cfg, indent=2))
def config_set(cfg, set_tuple):
def config_set(obj_id, cfg, set_tuple):
"""
Performs config --set for a given config
config is from a with json_rw context
config is from a "with json_rw" context
set_tuple is a tuple of the pathspec and the value
"""
import json
@ -109,4 +109,6 @@ def config_set(cfg, set_tuple):
if key not in cfg:
logger.error("Path not found")
return -1
cfg[key] = value
old_value = cfg[key]
cfg[key] = value
logger.info("{}.{}: {} -> {}".format(obj_id, pathspec, old_value, value))

View File

@ -110,7 +110,7 @@ def command_config(args):
if args.set:
with json_rw(lex.config_path) as cfg:
config_set(cfg, args.set)
config_set(lex.id, cfg, args.set)
#
# Player/character commands

View File

@ -90,4 +90,4 @@ def command_config(args):
if args.set:
with config.json_rw('config.json') as cfg:
config_set(cfg, args.set)
config_set("config", cfg, args.set)

View File

@ -99,7 +99,7 @@ def command_config(args):
if args.set:
with config.json_rw('user', u.id, 'config.json') as cfg:
config_set(cfg, args.set)
config_set(u.id, cfg, args.set)
@add_argument("--username", help="The user to change password for")
def command_passwd(args):