Skip to content

Commit

Permalink
CLI output pipes: Add CLICON_PIPETREE to any cli files, not just the …
Browse files Browse the repository at this point in the history
…first
  • Loading branch information
olofhagsand committed Aug 9, 2023
1 parent cdc305e commit 6d53603
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 4 additions & 5 deletions apps/cli/cli_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion test/test_cli_pipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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> ";
Expand All @@ -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);
Expand Down

0 comments on commit 6d53603

Please sign in to comment.