CLI configurable format: [Default format should be configurable](https://github.com/clicon/clixon-controller/issues/87)

Added option: `CLICON_CLI_OUTPUT_FORMAT` - Default CLI output format
This commit is contained in:
Olof hagsand 2024-04-05 15:13:24 +02:00
parent bd3a841103
commit 60a774cbf7
18 changed files with 168 additions and 83 deletions

View file

@ -41,6 +41,9 @@ edit @datamodelmode, cli_auto_edit("basemodel");
up, cli_auto_up("basemodel");
top, cli_auto_top("basemodel");
set @datamodel, cli_auto_set();
set default {
format("Set default output format") <fmt:string choice:xml|json|text|cli>("CLI output format"), cli_format_set();
}
merge @datamodel, cli_auto_merge();
create @datamodel, cli_auto_create();
delete("Delete a configuration item") {
@ -77,18 +80,17 @@ copy("Copy and create a new object") {
discard("Discard edits (rollback 0)"), discard_changes();
show("Show a particular state of the system"){
default{
format("Show default output format"), cli_format_show();
}
auto("Show expand x"){
xml @datamodelshow, cli_show_auto("candidate", "xml", true, false, "report-all");
text @datamodelshow, cli_show_auto("candidate", "text", true, false, "report-all");
json @datamodelshow, cli_show_auto("candidate", "json", true, false, "report-all");
netconf @datamodelshow, cli_show_auto("candidate", "netconf", true, false, "report-all");
cli @datamodelshow, cli_show_auto("candidate", "cli", true, false, "report-all", "set ");
@datamodelshow, cli_show_auto("candidate", "default", true, false, "report-all");
}
xpath("Show configuration") <xpath:string>("XPATH expression")
[<ns:string>("Namespace")], show_conf_xpath("candidate");
version("Show version"), cli_show_version("candidate", "text", "/");
options("Show clixon options"), cli_show_options();
compare("Compare candidate and running databases"), compare_dbs("running", "candidate", "xml");{
compare("Compare candidate and running databases"), compare_dbs("running", "candidate", "default");{
xml("Show comparison in xml"), compare_dbs("running", "candidate", "xml");
text("Show comparison in text"), compare_dbs("running", "candidate", "text");
}
@ -98,32 +100,25 @@ show("Show a particular state of the system"){
text, cli_pagination("use xpath var", "es", "http://example.com/ns/example-social", "text", "10");
json, cli_pagination("use xpath var", "es", "http://example.com/ns/example-social", "json", "10");
}
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", true, false);{
default("With-default mode"){
report-all, cli_show_auto_mode("candidate", "xml", true, false, "report-all");
trim, cli_show_auto_mode("candidate", "xml", true, false, "trim");
explicit, cli_show_auto_mode("candidate", "xml", true, false, "explicit");
report-all-tagged, cli_show_auto_mode("candidate", "xml", true, false, "report-all-tagged");
report-all-tagged-default, cli_show_auto_mode("candidate", "xml", true, false, "report-all-tagged-default");
report-all-tagged-strip, cli_show_auto_mode("candidate", "xml", true, false, "report-all-tagged-strip");
}
}
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", true, false, "explicit", "set ");
netconf("Show configuration as netconf edit-config operation"), cli_show_auto_mode("candidate", "netconf", true, false);
text("Show configuration as text"), cli_show_auto_mode("candidate", "text", true, false);
json("Show configuration as JSON"), cli_show_auto_mode("candidate", "json", true, false);
configuration("Show configuration"), cli_show_auto_mode("candidate", "default", true, false, "explicit", "set ");{
default("With-default mode"){
report-all, cli_show_auto_mode("candidate", "default", true, false, "report-all");
trim, cli_show_auto_mode("candidate", "default", true, false, "trim");
explicit, cli_show_auto_mode("candidate", "default", true, false, "explicit");
report-all-tagged, cli_show_auto_mode("candidate", "default", true, false, "report-all-tagged");
report-all-tagged-default, cli_show_auto_mode("candidate", "default", true, false, "report-all-tagged-default");
report-all-tagged-strip, cli_show_auto_mode("candidate", "default", true, false, "report-all-tagged-strip");
}
}
state("Show configuration and state"), cli_show_auto_mode("running", "text", true, true); {
xml("Show configuration and state as XML"), cli_show_auto_mode("running", "xml", true, true);{
state("Show configuration and state"), cli_show_auto_mode("running", "default", true, true); {
xml("Show configuration and state as XML"), cli_show_auto_mode("running", "default", true, true);{
default("With-default mode"){
report-all, cli_show_auto_mode("running", "xml", true, true, "report-all");
trim, cli_show_auto_mode("running", "xml", true, true, "trim");
explicit, cli_show_auto_mode("running", "xml", true, true, "explicit");
report-all-tagged, cli_show_auto_mode("running", "xml", true, true, "report-all-tagged");
report-all-tagged-default, cli_show_auto_mode("running", "xml", true, true, "report-all-tagged-default");
report-all-tagged-strip, cli_show_auto_mode("running", "xml", true, true, "report-all-tagged-strip");
report-all, cli_show_auto_mode("running", "default", true, true, "report-all");
trim, cli_show_auto_mode("running", "default", true, true, "trim");
explicit, cli_show_auto_mode("running", "default", true, true, "explicit");
report-all-tagged, cli_show_auto_mode("running", "default", true, true, "report-all-tagged");
report-all-tagged-default, cli_show_auto_mode("running", "default", true, true, "report-all-tagged-default");
report-all-tagged-strip, cli_show_auto_mode("running", "default", true, true, "report-all-tagged-strip");
}
}
}