From 94bce2f65b123c255aac4cbf4adb029540889b98 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 8 Feb 2018 19:39:39 -0500 Subject: [PATCH] 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. --- confluent_client/bin/nodeconfig | 38 +++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/confluent_client/bin/nodeconfig b/confluent_client/bin/nodeconfig index 01bdd278..6055e315 100755 --- a/confluent_client/bin/nodeconfig +++ b/confluent_client/bin/nodeconfig @@ -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