summaryrefslogtreecommitdiff
path: root/scripts/build-command-templates
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2017-09-14 03:42:22 +0200
committerDaniil Baturin <daniil@baturin.org>2017-09-14 03:42:22 +0200
commit4d1e6f378a9e99c6168e872ab8e795382514851e (patch)
treefe10ddddc7d00edb2eb358f99c525e60a84dc643 /scripts/build-command-templates
parentf6f2d9114bc4ed9a176be51b537c0d4e3d1cf734 (diff)
downloadvyos-1x-4d1e6f378a9e99c6168e872ab8e795382514851e.tar.gz
vyos-1x-4d1e6f378a9e99c6168e872ab8e795382514851e.zip
T392: add support for completionHelp to the interface definition converter.
Diffstat (limited to 'scripts/build-command-templates')
-rwxr-xr-xscripts/build-command-templates28
1 files changed, 28 insertions, 0 deletions
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):