Add draft `brokercnf` CLI cmd from @guilledk
parent
f99e8fe7eb
commit
d3a504864a
|
@ -485,3 +485,68 @@ def search(config, pattern):
|
|||
return
|
||||
|
||||
click.echo(colorize_json(quotes))
|
||||
|
||||
|
||||
# @cli.command()
|
||||
# @click.argument('section', required=True)
|
||||
# @click.argument('value', required=False)
|
||||
# @click.option('--delete', '-d', flag_value=True, help='Delete section')
|
||||
# @click.pass_obj
|
||||
# def brokercfg(config, section, value, delete):
|
||||
# from .. import config
|
||||
# conf, path = config.load()
|
||||
|
||||
# # XXX: Recursive getting & setting
|
||||
|
||||
# def get_value(_dict, _section):
|
||||
# subs = _section.split('.')
|
||||
# if len(subs) > 1:
|
||||
# return get_value(
|
||||
# _dict[subs[0]],
|
||||
# '.'.join(subs[1:]),
|
||||
# )
|
||||
|
||||
# else:
|
||||
# return _dict[_section]
|
||||
|
||||
# def set_value(_dict, _section, val):
|
||||
# subs = _section.split('.')
|
||||
# if len(subs) > 1:
|
||||
# if subs[0] not in _dict:
|
||||
# _dict[subs[0]] = {}
|
||||
|
||||
# return set_value(
|
||||
# _dict[subs[0]],
|
||||
# '.'.join(subs[1:]),
|
||||
# val
|
||||
# )
|
||||
|
||||
# else:
|
||||
# _dict[_section] = val
|
||||
|
||||
# def del_value(_dict, _section):
|
||||
# subs = _section.split('.')
|
||||
# if len(subs) > 1:
|
||||
# if subs[0] not in _dict:
|
||||
# return
|
||||
|
||||
# return del_value(
|
||||
# _dict[subs[0]],
|
||||
# '.'.join(subs[1:])
|
||||
# )
|
||||
|
||||
# else:
|
||||
# if _section not in _dict:
|
||||
# return
|
||||
|
||||
# del _dict[_section]
|
||||
|
||||
# if not delete:
|
||||
# if value:
|
||||
# set_value(conf, section, value)
|
||||
|
||||
# click.echo(colorize_json(get_value(conf, section)))
|
||||
# else:
|
||||
# del_value(conf, section)
|
||||
|
||||
# broker_conf.write(conf)
|
||||
|
|
Loading…
Reference in New Issue