2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-02-16 18:49:04 +00:00

Unofficially tolerate pasu and own input

If someone tries to use this with pasu syntax, try to do the right
thing.  Similarly, if trying to paste the same syntax nodeconfig
uses on output, tolerate that as well.
This commit is contained in:
Jarrod Johnson 2018-02-08 19:39:39 -05:00
parent cc16aed27a
commit 94bce2f65b

View File

@ -84,6 +84,8 @@ assignment = {}
queryparms = {}
printsys = []
setsys = {}
forceset = False
needval = None
if len(args) == 1 or options.exclude:
if not options.exclude:
@ -94,18 +96,40 @@ if len(args) == 1 or options.exclude:
if path not in queryparms:
queryparms[path] = {}
queryparms[path][attrib] = candidate
def _assign_value():
if key not in cfgpaths:
setsys[key] = value
for depkey, depval in autodeps.get(key, []):
assignment[depkey] = depval
assignment[key] = value
for param in args[1:]:
if '=' in param:
if param == 'show':
continue # forgive muscle memory of pasu users
if param == 'set':
setmode = True
forceset = True
continue
if needval:
key = needval
value = param
_assign_value()
continue
if '=' in param or param[-1] == ':' or forceset:
if setmode is None:
setmode = True
if setmode != True:
bailout('Cannot do set and query in same command')
key, _, value = param.partition('=')
if key not in cfgpaths:
setsys[key] = value
for depkey, depval in autodeps.get(key, []):
assignment[depkey] = depval
assignment[key] = value
if '=' in param:
key, _, value = param.partition('=')
_assign_value()
elif param[-1] == ':':
needval = param[:-1]
else:
needval = param
else:
if setmode is None:
setmode = False