Use new config get/set API in `brokercnf` cmd?
parent
e03da40867
commit
e85e031df7
|
@ -487,66 +487,35 @@ def search(config, pattern):
|
||||||
click.echo(colorize_json(quotes))
|
click.echo(colorize_json(quotes))
|
||||||
|
|
||||||
|
|
||||||
# @cli.command()
|
@cli.command()
|
||||||
# @click.argument('section', required=True)
|
@click.argument('section', required=False)
|
||||||
# @click.argument('value', required=False)
|
@click.argument('value', required=False)
|
||||||
# @click.option('--delete', '-d', flag_value=True, help='Delete section')
|
@click.option('--delete', '-d', flag_value=True, help='Delete section')
|
||||||
# @click.pass_obj
|
@click.pass_obj
|
||||||
# def brokercfg(config, section, value, delete):
|
def brokercfg(config, section, value, delete):
|
||||||
# from .. import config
|
"""If invoked with no arguments, open an editor to edit broker configs file
|
||||||
# conf, path = config.load()
|
or get / update an individual section.
|
||||||
|
"""
|
||||||
|
from .. import config
|
||||||
|
|
||||||
# # XXX: Recursive getting & setting
|
if section:
|
||||||
|
conf, path = config.load()
|
||||||
|
|
||||||
# def get_value(_dict, _section):
|
if not delete:
|
||||||
# subs = _section.split('.')
|
if value:
|
||||||
# if len(subs) > 1:
|
config.set_value(conf, section, value)
|
||||||
# return get_value(
|
|
||||||
# _dict[subs[0]],
|
|
||||||
# '.'.join(subs[1:]),
|
|
||||||
# )
|
|
||||||
|
|
||||||
# else:
|
click.echo(
|
||||||
# return _dict[_section]
|
colorize_json(
|
||||||
|
config.get_value(conf, section))
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
config.del_value(conf, section)
|
||||||
|
|
||||||
# def set_value(_dict, _section, val):
|
config.write(config=conf)
|
||||||
# subs = _section.split('.')
|
|
||||||
# if len(subs) > 1:
|
|
||||||
# if subs[0] not in _dict:
|
|
||||||
# _dict[subs[0]] = {}
|
|
||||||
|
|
||||||
# return set_value(
|
else:
|
||||||
# _dict[subs[0]],
|
conf, path = config.load(raw=True)
|
||||||
# '.'.join(subs[1:]),
|
config.write(
|
||||||
# val
|
raw=click.edit(text=conf)
|
||||||
# )
|
)
|
||||||
|
|
||||||
# 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