completing the function of hide for autocli-op in the yang files
This commit is contained in:
parent
8ca5944111
commit
c370ac8706
16 changed files with 98 additions and 44 deletions
|
|
@ -413,10 +413,10 @@ cli_auto_show(clicon_handle h,
|
|||
switch (format){
|
||||
case FORMAT_XML:
|
||||
if (isroot)
|
||||
clicon_xml2file(stdout, xp, 0, pretty);
|
||||
clicon_xml2file(stdout, xp, 0, pretty, 1);
|
||||
else{
|
||||
while ((xc = xml_child_each(xp, xc, CX_ELMNT)) != NULL)
|
||||
clicon_xml2file(stdout, xc, 0, pretty);
|
||||
clicon_xml2file(stdout, xc, 0, pretty, 1);
|
||||
}
|
||||
fprintf(stdout, "\n");
|
||||
break;
|
||||
|
|
@ -451,10 +451,10 @@ cli_auto_show(clicon_handle h,
|
|||
if (pretty)
|
||||
fprintf(stdout, "\n");
|
||||
if (isroot)
|
||||
clicon_xml2file(stdout, xp, 2, pretty);
|
||||
clicon_xml2file(stdout, xp, 2, pretty, 1);
|
||||
else
|
||||
while ((xc = xml_child_each(xp, xc, CX_ELMNT)) != NULL)
|
||||
clicon_xml2file(stdout, xc, 2, pretty);
|
||||
clicon_xml2file(stdout, xc, 2, pretty, 1);
|
||||
fprintf(stdout, "</config></edit-config></rpc>]]>]]>\n");
|
||||
break;
|
||||
} /* switch */
|
||||
|
|
|
|||
|
|
@ -676,7 +676,7 @@ compare_xmls(cxobj *xc1,
|
|||
xml2txt_cb(f, xc, cligen_output);
|
||||
else
|
||||
while ((xc = xml_child_each(xc1, xc, -1)) != NULL)
|
||||
clicon_xml2file_cb(f, xc, 0, 1, cligen_output);
|
||||
clicon_xml2file_cb(f, xc, 0, 1, cligen_output, 0);
|
||||
|
||||
fclose(f);
|
||||
close(fd);
|
||||
|
|
@ -693,7 +693,7 @@ compare_xmls(cxobj *xc1,
|
|||
xml2txt_cb(f, xc, cligen_output);
|
||||
else
|
||||
while ((xc = xml_child_each(xc2, xc, -1)) != NULL)
|
||||
clicon_xml2file_cb(f, xc, 0, 1, cligen_output);
|
||||
clicon_xml2file_cb(f, xc, 0, 1, cligen_output, 0);
|
||||
fclose(f);
|
||||
close(fd);
|
||||
|
||||
|
|
@ -923,7 +923,7 @@ save_config_file(clicon_handle h,
|
|||
clicon_err(OE_CFG, errno, "Creating file %s", filename);
|
||||
goto done;
|
||||
}
|
||||
if (clicon_xml2file(f, xt, 0, 1) < 0)
|
||||
if (clicon_xml2file(f, xt, 0, 1, 0) < 0)
|
||||
goto done;
|
||||
retval = 0;
|
||||
/* Fall through */
|
||||
|
|
@ -1029,7 +1029,7 @@ cli_notification_cb(int s,
|
|||
while ((x = xml_child_each(xe, x, -1)) != NULL) {
|
||||
switch (format){
|
||||
case FORMAT_XML:
|
||||
if (clicon_xml2file_cb(stdout, x, 0, 1, cligen_output) < 0)
|
||||
if (clicon_xml2file_cb(stdout, x, 0, 1, cligen_output, 0) < 0)
|
||||
goto done;
|
||||
break;
|
||||
case FORMAT_TEXT:
|
||||
|
|
|
|||
|
|
@ -119,7 +119,14 @@ cli_expand_var_generate(clicon_handle h,
|
|||
cbuf *cb)
|
||||
{
|
||||
int retval = -1;
|
||||
char *api_path_fmt = NULL;
|
||||
char *api_path_fmt = NULL, *opext = NULL;
|
||||
|
||||
if (yang_extension_value(ys, "autocli-op", CLIXON_LIB_NS, &opext) < 0)
|
||||
goto done;
|
||||
if (opext && strcmp(opext, "hide-database") == 0) {
|
||||
retval = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (yang2api_path_fmt(ys, 1, &api_path_fmt) < 0)
|
||||
goto done;
|
||||
|
|
@ -574,7 +581,7 @@ yang2cli_var(clicon_handle h,
|
|||
uint8_t fraction_digits = 0;
|
||||
enum cv_type cvtype;
|
||||
int options = 0;
|
||||
int completionp;
|
||||
int completionp, result;
|
||||
char *type;
|
||||
|
||||
if ((patterns = cvec_new(0)) == NULL){
|
||||
|
|
@ -599,9 +606,10 @@ yang2cli_var(clicon_handle h,
|
|||
if (yang2cli_var_union(h, ys, origtype, yrestype, helptext, cb) < 0)
|
||||
goto done;
|
||||
if (clicon_cli_genmodel_completion(h)){
|
||||
if (cli_expand_var_generate(h, ys, cvtype,
|
||||
result = cli_expand_var_generate(h, ys, cvtype,
|
||||
options, fraction_digits,
|
||||
cb) < 0)
|
||||
cb);
|
||||
if (result < 0)
|
||||
goto done;
|
||||
yang2cli_helptext(cb, helptext);
|
||||
}
|
||||
|
|
@ -622,9 +630,10 @@ yang2cli_var(clicon_handle h,
|
|||
options, cvv, patterns, fraction_digits, cb)) < 0)
|
||||
goto done;
|
||||
if (completionp){
|
||||
if (cli_expand_var_generate(h, ys, cvtype,
|
||||
result = cli_expand_var_generate(h, ys, cvtype,
|
||||
options, fraction_digits,
|
||||
cb) < 0)
|
||||
cb);
|
||||
if (result < 0)
|
||||
goto done;
|
||||
yang2cli_helptext(cb, helptext);
|
||||
cprintf(cb, ")");
|
||||
|
|
@ -688,6 +697,10 @@ yang2cli_leaf(clicon_handle h,
|
|||
cprintf(cb, ",hide{");
|
||||
extralevel = 1;
|
||||
}
|
||||
if (opext && strcmp(opext, "hide-database-auto-completion") == 0){
|
||||
cprintf(cb, ",hide-database-auto-completion{");
|
||||
extralevel = 1;
|
||||
}
|
||||
if (yang2cli_var(h, ys, helptext, cb) < 0)
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -695,6 +708,9 @@ yang2cli_leaf(clicon_handle h,
|
|||
if (opext && strcmp(opext, "hide") == 0){
|
||||
cprintf(cb, ",hide");
|
||||
}
|
||||
if (opext && strcmp(opext, "hide-database-auto-completion") == 0){
|
||||
cprintf(cb, ",hide-database-auto-completion");
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
|
@ -767,6 +783,9 @@ yang2cli_container(clicon_handle h,
|
|||
if (opext != NULL && strcmp(opext, "hide") == 0){
|
||||
cprintf(cb, ",hide");
|
||||
}
|
||||
if (opext != NULL && strcmp(opext, "hide-database-auto-completion") == 0){
|
||||
cprintf(cb, ",hide-database-auto-completion");
|
||||
}
|
||||
cprintf(cb, ";{\n");
|
||||
}
|
||||
|
||||
|
|
@ -822,6 +841,10 @@ yang2cli_list(clicon_handle h,
|
|||
cprintf(cb, ",hide");
|
||||
extralevel = 1;
|
||||
}
|
||||
if (opext != NULL && strcmp(opext, "hide-database-auto-completion") == 0){
|
||||
cprintf(cb, ",hide-database-auto-completion");
|
||||
extralevel = 1;
|
||||
}
|
||||
if ((yd = yang_find(ys, Y_DESCRIPTION, NULL)) != NULL){
|
||||
if ((helptext = strdup(yang_argument_get(yd))) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "strdup");
|
||||
|
|
|
|||
|
|
@ -476,7 +476,7 @@ cli_show_config1(clicon_handle h,
|
|||
case FORMAT_XML:
|
||||
xc = NULL; /* Dont print xt itself */
|
||||
while ((xc = xml_child_each(xt, xc, -1)) != NULL)
|
||||
clicon_xml2file_cb(stdout, xc, 0, 1, cligen_output);
|
||||
clicon_xml2file_cb(stdout, xc, 0, 1, cligen_output, 1);
|
||||
break;
|
||||
case FORMAT_JSON:
|
||||
xml2json_cb(stdout, xt, 1, cligen_output);
|
||||
|
|
@ -499,7 +499,7 @@ cli_show_config1(clicon_handle h,
|
|||
NETCONF_BASE_NAMESPACE);
|
||||
xc = NULL; /* Dont print xt itself */
|
||||
while ((xc = xml_child_each(xt, xc, -1)) != NULL)
|
||||
clicon_xml2file_cb(stdout, xc, 2, 1, cligen_output);
|
||||
clicon_xml2file_cb(stdout, xc, 2, 1, cligen_output, 1);
|
||||
cligen_output(stdout, "</config></edit-config></rpc>]]>]]>\n");
|
||||
break;
|
||||
}
|
||||
|
|
@ -747,14 +747,14 @@ cli_show_auto1(clicon_handle h,
|
|||
break;
|
||||
case FORMAT_NETCONF:
|
||||
fprintf(stdout, "<rpc><edit-config><target><candidate/></target><config>\n");
|
||||
clicon_xml2file(stdout, xp, 2, 1);
|
||||
clicon_xml2file(stdout, xp, 2, 1, 1);
|
||||
fprintf(stdout, "</config></edit-config></rpc>]]>]]>\n");
|
||||
break;
|
||||
default:
|
||||
for (; i < xml_child_nr(xml_parent(xp)) ; ++i, xp_helper = xml_child_i(xml_parent(xp), i)) {
|
||||
switch (format){
|
||||
case FORMAT_XML:
|
||||
clicon_xml2file(stdout, xp_helper, 0, 1);
|
||||
clicon_xml2file(stdout, xp_helper, 0, 1, 1);
|
||||
break;
|
||||
case FORMAT_JSON:
|
||||
xml2json_cb(stdout, xp_helper, 1, cligen_output);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue