* Changed CLI help strings behaviour on query (?) for long and multi-line help strings.

* If multiple strings (eg "\n" in text), indent before each new line
  * Primarily for auto-cli where long help strings are generated from YANG descriptions, but applies as well for manual long/multi-line help strings
  * New config option: `CLICON_CLI_HELPSTRING_TRUNCATE`: Truncate help string on right margin mode
  * New config option: `CLICON_CLI_HELPSTRING_LINES`: Limit of number of help strings to show
This commit is contained in:
Olof hagsand 2020-09-04 13:15:53 +02:00
parent 81fc7f742b
commit b8955c81d8
4 changed files with 52 additions and 18 deletions

View file

@ -40,12 +40,24 @@ Users may have to change how they access the system
* The fix of [Cannot create or modify NACM data node access rule with path using JSON encoding #129](https://github.com/clicon/clixon/issues/129) leads that data-node paths, eg `<rule>...<path>ex:table/ex:parameter</path></rule>` instance-identifiers are restricted to canonical namespace identifiers for both XML and JSON encoding. That is, if a symbol (such as `table` above) is a symbol in a module with prefix `ex`, another prefix cannot be used, even though defined with a `xmlns:` rule. * The fix of [Cannot create or modify NACM data node access rule with path using JSON encoding #129](https://github.com/clicon/clixon/issues/129) leads that data-node paths, eg `<rule>...<path>ex:table/ex:parameter</path></rule>` instance-identifiers are restricted to canonical namespace identifiers for both XML and JSON encoding. That is, if a symbol (such as `table` above) is a symbol in a module with prefix `ex`, another prefix cannot be used, even though defined with a `xmlns:` rule.
* New clixon-config@2020-08-17.yang revision * New clixon-config@2020-08-17.yang revision
* Added options for Restconf evhtp setting default bind socket address and ports `CLICON_RESTCONF_IPV4_ADDR`, `CLICON_RESTCONF_IPV6_ADDR`, `CLICON_RESTCONF_HTTP_PORT`, `CLICON_RESTCONF_HTTPS_PORT`, `CLICON_NAMESPACE_NETCONF_DEFAULT` * Added options for Restconf evhtp setting default bind socket address and ports:
* `CLICON_RESTCONF_IPV4_ADDR`, `CLICON_RESTCONF_IPV6_ADDR`, `CLICON_RESTCONF_HTTP_PORT`, `CLICON_RESTCONF_HTTPS_PORT`
* Added option for using NETCONF default namespace: `CLICON_NAMESPACE_NETCONF_DEFAULT`
* Added options for better handling of long and multi-line CLI help strings:
* `CLICON_CLI_HELPSTRING_TRUNCATE`, `CLICON_CLI_HELPSTRING_LINES`
### C/CLI-API changes on existing features ### C/CLI-API changes on existing features
Developers may need to change their code Developers may need to change their code
### Minor changes
* Changed CLI help strings behaviour on query (?) for long and multi-line help strings.
* If multiple strings (eg "\n" in text), indent before each new line
* Primarily for auto-cli where long help strings are generated from YANG descriptions, but applies as well for manual long/multi-line help strings
* New config option: `CLICON_CLI_HELPSTRING_TRUNCATE`: Truncate help string on right margin mode
* New config option: `CLICON_CLI_HELPSTRING_LINES`: Limit of number of help strings to show
### Corrected Bugs ### Corrected Bugs
* Fixed: [CLI crash if error-info is empty #134](https://github.com/clicon/clixon/issues/134) * Fixed: [CLI crash if error-info is empty #134](https://github.com/clicon/clixon/issues/134)

View file

@ -1317,5 +1317,5 @@ cli_help(clicon_handle h, cvec *vars, cvec *argv)
parse_tree *pt; parse_tree *pt;
pt = cligen_tree_active_get(ch); pt = cligen_tree_active_get(ch);
return cligen_help(stdout, pt); return cligen_help(ch, stdout, pt);
} }

View file

@ -392,6 +392,7 @@ main(int argc,
size_t cligen_buflen; size_t cligen_buflen;
size_t cligen_bufthreshold; size_t cligen_bufthreshold;
int dbg=0; int dbg=0;
int nr;
/* Defaults */ /* Defaults */
once = 0; once = 0;
@ -560,9 +561,8 @@ main(int argc,
/* Init row numbers for raw terminals */ /* Init row numbers for raw terminals */
if (clicon_option_exists(h, "CLICON_CLI_LINES_DEFAULT")){ if (clicon_option_exists(h, "CLICON_CLI_LINES_DEFAULT")){
int rows; nr = clicon_option_int(h, "CLICON_CLI_LINES_DEFAULT");
rows = clicon_option_int(h, "CLICON_CLI_LINES_DEFAULT"); cligen_terminal_rows_set(cli_cligen(h), nr);
cligen_terminal_rows_set(cli_cligen(h), rows);
} }
if (clicon_yang_regexp(h) == REGEXP_LIBXML2){ if (clicon_yang_regexp(h) == REGEXP_LIBXML2){
@ -575,6 +575,12 @@ main(int argc,
#endif #endif
} }
/* CLIgen help string setting for long and multi-line strings */
nr = clicon_option_int(h, "CLICON_CLI_HELPSTRING_TRUNCATE");
cligen_helpstring_truncate_set(cli_cligen(h), nr);
nr = clicon_option_int(h, "CLICON_CLI_HELPSTRING_LINES");
cligen_helpstring_lines_set(cli_cligen(h), nr);
/* Setup signal handlers */ /* Setup signal handlers */
cli_signal_init(h); cli_signal_init(h);

View file

@ -46,7 +46,8 @@ module clixon-config {
description description
"Added: CLICON_RESTCONF_IPV4_ADDR, CLICON_RESTCONF_IPV6_ADDR, "Added: CLICON_RESTCONF_IPV4_ADDR, CLICON_RESTCONF_IPV6_ADDR,
CLICON_RESTCONF_HTTP_PORT, CLICON_RESTCONF_HTTPS_PORT CLICON_RESTCONF_HTTP_PORT, CLICON_RESTCONF_HTTPS_PORT
CLICON_NAMESPACE_NETCONF_DEFAULT"; CLICON_NAMESPACE_NETCONF_DEFAULT,
CLICON_CLI_HELPSTRING_TRUNCATE, CLICON_CLI_HELPSTRING_LINES";
} }
revision 2020-06-17 { revision 2020-06-17 {
description description
@ -585,6 +586,22 @@ module clixon-config {
If 0, the growth continues with quadratic growth. If 0, the growth continues with quadratic growth.
See CLICON_CLI_BUF_THRESHOLD"; See CLICON_CLI_BUF_THRESHOLD";
} }
leaf CLICON_CLI_HELPSTRING_TRUNCATE {
type boolean;
default false;
description
"CLIgen help string on query (?): Truncate help string on right margin mode
This only applies if you have long help strings, such as when generating them from a
spec such as the autocli";
}
leaf CLICON_CLI_HELPSTRING_LINES {
type int32;
default 0;
description
"CLIgen help string on query (?) limit of number of lines to show, 0 means unlimited.
This only applies if you have multi-line help strings, such as when generating
from a spec, such as in the autocli.";
}
leaf CLICON_SOCK_FAMILY { leaf CLICON_SOCK_FAMILY {
type string; type string;
default "UNIX"; default "UNIX";
@ -712,6 +729,17 @@ module clixon-config {
lists, therefore it is recommended to enable it during development and debugging lists, therefore it is recommended to enable it during development and debugging
but disable it in production, until this has been resolved."; but disable it in production, until this has been resolved.";
} }
leaf CLICON_NAMESPACE_NETCONF_DEFAULT {
type boolean;
default false;
description
"Undefine if you want to ensure strict namespace assignment on all netconf
and XML statements according to the standard RFC 6241.
If defined, top-level rpc calls need not have namespaces (eg using xmlns=<ns>)
since the default NETCONF namespace will be assumed. (This is not standard).
See rfc6241 3.1: urn:ietf:params:xml:ns:netconf:base:1.0.";
}
leaf CLICON_STARTUP_MODE { leaf CLICON_STARTUP_MODE {
type startup_mode; type startup_mode;
description "Which method to boot/start clicon backend"; description "Which method to boot/start clicon backend";
@ -836,17 +864,5 @@ module clixon-config {
data to store before dropping. 0 means no retention"; data to store before dropping. 0 means no retention";
} }
leaf CLICON_NAMESPACE_NETCONF_DEFAULT {
type boolean;
default false;
description
"Undefine if you want to ensure strict namespace assignment on all netconf
and XML statements according to the standard RFC 6241.
If defined, top-level rpc calls need not have namespaces (eg using xmlns=<ns>)
since the default NETCONF namespace will be assumed. (This is not standard).
See rfc6241 3.1: urn:ietf:params:xml:ns:netconf:base:1.0.";
}
} }
} }