From 4d1e6f378a9e99c6168e872ab8e795382514851e Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 14 Sep 2017 03:42:22 +0200 Subject: T392: add support for completionHelp to the interface definition converter. --- scripts/build-command-templates | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'scripts') diff --git a/scripts/build-command-templates b/scripts/build-command-templates index 0bac920fb..6801defbb 100755 --- a/scripts/build-command-templates +++ b/scripts/build-command-templates @@ -109,6 +109,29 @@ def get_properties(p): except: props["val_help"] = [] + # Get the completion help strings + try: + che = p.findall("completionHelp") + ch = "" + for c in che: + scripts = c.findall("script") + paths = c.findall("path") + lists = c.findall("list") + + # Current backend doesn't support multiple allowed: tags + # so we get to emulate it + comp_exprs = [] + for i in lists: + comp_exprs.append("echo \"{0}\"".format(i.text)) + for i in paths: + comp_exprs.append("/bin/cli-shell-api listNodes {0}".format(i.text)) + for i in scripts: + comp_exprs.append("sh -c \"{0}\"".format(i.text)) + comp_help = " && ".join(comp_exprs) + props["comp_help"] = comp_help + except: + props["comp_help"] = [] + # Get priority try: props["priority"] = p.find("priority").text @@ -146,10 +169,15 @@ def make_node_def(props): for v in props["val_help"]: node_def += "val_help: {0}; {1}\n".format(v[0], v[1]) + if "comp_help" in props: + node_def += "allowed: {0}\n".format(props["comp_help"]) + if "owner" in props: node_def += "end: sudo sh -c \"{0}\"\n".format(props["owner"]) + if debug: print("The content of node_def:", node_def) + return node_def def process_node(n, tmpl_dir): -- cgit v1.2.3