mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 15:24:43 +00:00
tools: teach xml2cli.pl the "[]" notation for optional arguments
Requested by Daniel Walton. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
6bfae35e5c
commit
bdcf7abf82
@ -141,6 +141,8 @@ sub generate_arguments {
|
|||||||
# argument is the name of the node
|
# argument is the name of the node
|
||||||
if ($node{'input'} or $node{'type'} eq "select") {
|
if ($node{'input'} or $node{'type'} eq "select") {
|
||||||
$arg_value = "argv[" . $argc . "]->arg";
|
$arg_value = "argv[" . $argc . "]->arg";
|
||||||
|
} elsif ($node{'optional'}) {
|
||||||
|
$arg_value = "(argc > " . $argc . " ? argv[" . $argc. "]->arg : NULL)";
|
||||||
} else {
|
} else {
|
||||||
$arg_value = '"' . $node{'name'} . '"';
|
$arg_value = '"' . $node{'name'} . '"';
|
||||||
}
|
}
|
||||||
@ -196,7 +198,11 @@ sub generate_code {
|
|||||||
$helpstr .= $::options{$options_name}{'help'};
|
$helpstr .= $::options{$options_name}{'help'};
|
||||||
} else {
|
} else {
|
||||||
$funcname .= $node{'name'} . " ";
|
$funcname .= $node{'name'} . " ";
|
||||||
|
if ($node{'optional'}) {
|
||||||
|
$cmdstr .= "[" . $node{'name'} . "] ";
|
||||||
|
} else {
|
||||||
$cmdstr .= $node{'name'} . " ";
|
$cmdstr .= $node{'name'} . " ";
|
||||||
|
}
|
||||||
$helpstr .= "\n \"" . $node{'help'} . "\\n\"";
|
$helpstr .= "\n \"" . $node{'help'} . "\\n\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,6 +285,7 @@ sub parse_tree {
|
|||||||
$node{'help'} = $xml_node->findvalue('./@help');
|
$node{'help'} = $xml_node->findvalue('./@help');
|
||||||
$node{'function'} = $xml_node->findvalue('./@function');
|
$node{'function'} = $xml_node->findvalue('./@function');
|
||||||
$node{'ifdef'} = $xml_node->findvalue('./@ifdef');
|
$node{'ifdef'} = $xml_node->findvalue('./@ifdef');
|
||||||
|
$node{'optional'} = $xml_node->findvalue('./@optional');
|
||||||
|
|
||||||
# push node to stack
|
# push node to stack
|
||||||
push (@nodes, \%node);
|
push (@nodes, \%node);
|
||||||
|
Loading…
Reference in New Issue
Block a user