* Auto-CLI enhancements

* A generated clispec including state (default @datanodestate) also generated along with the config clispec tree (default @datanode)
  * New mode `GT_HIDE` set by option `CLICON_CLI_GENMODEL_TYPE` to collapse non-presence containers that only contain a single list
  * Added a prfix for cli_show_config/cli_show_auto so that it can produce parseable output
  * Thanks dcornejo@netgate.com for trying it out and suggestions
This commit is contained in:
Olof hagsand 2020-06-13 12:05:26 +02:00
parent e2d9c046af
commit e898dda016
16 changed files with 319 additions and 86 deletions

View file

@ -547,17 +547,37 @@ main(int argc,
*/
if (clicon_cli_genmodel(h)){
parse_tree *pt = NULL; /* cli parse tree */
char *treeref;
cbuf *cbtreename;
parse_tree *pts = NULL; /* cli parse tree */
if ((pt = pt_new()) == NULL){
clicon_err(OE_UNIX, errno, "pt_new");
goto done;
}
treeref = clicon_cli_model_treename(h);
/* Create cli command tree from dbspec */
if (yang2cli(h, yspec, clicon_cli_genmodel_type(h), printgen, pt) < 0)
if ((cbtreename = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
goto done;
cligen_tree_add(cli_cligen(h), treeref, pt);
}
cprintf(cbtreename, "%s", clicon_cli_model_treename(h));
/* Create cli command tree from dbspec
* label this tree @datamodel per default
*/
if (yang2cli(h, yspec, clicon_cli_genmodel_type(h), printgen, 0, pt) < 0)
goto done;
cligen_tree_add(cli_cligen(h), cbuf_get(cbtreename), pt);
/* same for config+state
* label this tree @datamodelstate per default
*/
if ((pts = pt_new()) == NULL){
clicon_err(OE_UNIX, errno, "pt_new");
goto done;
}
cprintf(cbtreename, "state");
if (yang2cli(h, yspec, clicon_cli_genmodel_type(h), 0, 1, pts) < 0)
goto done;
cligen_tree_add(cli_cligen(h), cbuf_get(cbtreename), pts);
if (cbtreename)
cbuf_free(cbtreename);
}
/* Initialize cli syntax */