summaryrefslogtreecommitdiff
path: root/tools/xml2cli.pl
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-01-17 21:01:56 -0500
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-01-17 21:01:56 -0500
commitb58ed1f8a89ea32c2380bf79057e5333109d72d4 (patch)
treea9ead45b8895edce92ab69621a52816b45725e36 /tools/xml2cli.pl
parent01cb1466423363a2f8b42246464feb3858df1c9f (diff)
parent5551c072e187c76c3d6a885cd043d6db811bab23 (diff)
Merge remote-tracking branch 'origin/master' into pim_lib_work2
Diffstat (limited to 'tools/xml2cli.pl')
-rwxr-xr-xtools/xml2cli.pl9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/xml2cli.pl b/tools/xml2cli.pl
index 1b45e7f726..e0980421bd 100755
--- a/tools/xml2cli.pl
+++ b/tools/xml2cli.pl
@@ -141,6 +141,8 @@ sub generate_arguments {
# argument is the name of the node
if ($node{'input'} or $node{'type'} eq "select") {
$arg_value = "argv[" . $argc . "]->arg";
+ } elsif ($node{'optional'}) {
+ $arg_value = "(argc > " . $argc . " ? argv[" . $argc. "]->arg : NULL)";
} else {
$arg_value = '"' . $node{'name'} . '"';
}
@@ -196,7 +198,11 @@ sub generate_code {
$helpstr .= $::options{$options_name}{'help'};
} else {
$funcname .= $node{'name'} . " ";
- $cmdstr .= $node{'name'} . " ";
+ if ($node{'optional'}) {
+ $cmdstr .= "[" . $node{'name'} . "] ";
+ } else {
+ $cmdstr .= $node{'name'} . " ";
+ }
$helpstr .= "\n \"" . $node{'help'} . "\\n\"";
}
@@ -279,6 +285,7 @@ sub parse_tree {
$node{'help'} = $xml_node->findvalue('./@help');
$node{'function'} = $xml_node->findvalue('./@function');
$node{'ifdef'} = $xml_node->findvalue('./@ifdef');
+ $node{'optional'} = $xml_node->findvalue('./@optional');
# push node to stack
push (@nodes, \%node);