CLI output pipes: Add CLICON_PIPETREE to any cli files, not just the first

This commit is contained in:
Olof hagsand 2023-08-09 18:48:22 +02:00
parent cdc305ed2f
commit 6d53603c55
3 changed files with 14 additions and 6 deletions

View file

@ -48,6 +48,10 @@ Expected: October 2023
* Clarified clixon_cli command-line: `clixon_cli [options] [commands] [-- extra-options]`
### Corrected Bugs
* Fixed: CLI output pipes: Add CLICON_PIPETREE to any cli files, not just the first
## 6.3.0
29 July 2023

View file

@ -88,7 +88,6 @@ static int
gen_parse_tree(clicon_handle h,
char *name,
parse_tree *pt,
char *pipetree,
pt_head **php)
{
int retval = -1;
@ -102,9 +101,6 @@ gen_parse_tree(clicon_handle h,
clicon_err(OE_UNIX, errno, "cligen_ph_prompt_set");
goto done;
}
if (pipetree &&
cligen_ph_pipe_set(ph, pipetree) < 0)
goto done;
*php = ph;
retval = 0;
done:
@ -328,7 +324,7 @@ clispec_load_file(clicon_handle h,
clicon_err(OE_UNIX, errno, "pt_new");
goto done;
}
if (gen_parse_tree(h, name, ptnew, pipetree, &ph) < 0)
if (gen_parse_tree(h, name, ptnew, &ph) < 0)
goto done;
if (ph == NULL)
goto done;
@ -344,6 +340,9 @@ clispec_load_file(clicon_handle h,
if (cv)
cv_free(cv);
}
if (pipetree) /* Set if any file has it (never reset) */
if (cligen_ph_pipe_set(ph, pipetree) < 0)
goto done;
if (cligen_parsetree_merge(cligen_ph_parsetree_get(ph), NULL, pt) < 0){
clicon_err(OE_PLUGIN, errno, "cligen_parsetree_merge");
goto done;

View file

@ -88,6 +88,12 @@ show("Show a particular state of the system"){
}
EOF
# First file of mode does not have CLICON_PIPETREE, next have
cat <<EOF > $clidir/before.cli
CLICON_MODE="default";
dummy;
EOF
cat <<EOF > $clidir/default.cli
CLICON_MODE="default";
CLICON_PROMPT="%U@%H %W> ";
@ -110,7 +116,6 @@ EOF
cat <<EOF > $clidir/treeref.cli
CLICON_MODE="treeref";
CLICON_PIPETREE="|mypipe";
implicit("Show configuration"), cli_show_auto_mode("candidate", "xml", true, false);
explicit("Show configuration"), cli_show_auto_mode("candidate", "xml", true, false);{
@|mypipe, cli_show_auto_mode("candidate", "xml", true, false);