Example: added cli pipe

This commit is contained in:
Olof hagsand 2024-04-09 14:20:45 +02:00
parent 826a4c3fb3
commit f9faf1039a
8 changed files with 72 additions and 28 deletions

View file

@ -103,7 +103,8 @@ all: $(PLUGINS)
.c.o:
$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $<
CLISPECS = $(APPNAME)_cli.cli
CLISPECS = $(APPNAME)_cli.cli
CLISPECS += $(APPNAME)_pipe.cli
YANGSPECS = clixon-example@2022-11-01.yang

View file

@ -94,13 +94,9 @@ show("Show a particular state of the system"){
xml("Show comparison in xml"), compare_dbs("running", "candidate", "xml");
text("Show comparison in text"), compare_dbs("running", "candidate", "text");
}
pagination("Show list pagination") xpath("Show configuration") <xpath:string>("XPATH expression"){
xml, cli_pagination("use xpath var", "es", "http://example.com/ns/example-social", "xml", "10");
cli, cli_pagination("use xpath var", "es", "http://example.com/ns/example-social", "cli", "10");
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");
}
pagination("Show list pagination") xpath("Show configuration") <xpath:string>("XPATH expression"), cli_pagination("use xpath var", "es", "http://example.com/ns/example-social", "default", "10");
configuration("Show configuration"), cli_show_auto_mode("candidate", "default", true, false, "explicit", "set ");{
@|example_pipe, cli_show_auto_mode("candidate", "xml", true, false, "explicit");
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");
@ -111,16 +107,15 @@ show("Show a particular state of the system"){
}
}
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", "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");
}
}
@|example_pipe, cli_show_auto_mode("running", "xml", true, true);
default("With-default mode"){
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");
}
}
yang("Show yang specs"), show_yang(); {
clixon-example("Show clixon-example yang spec"), show_yang("clixon-example");

View file

@ -0,0 +1,47 @@
# ***** BEGIN LICENSE BLOCK *****
#
# Copyright (C) 2024 Olof Hagsand
#
# This file is part of CLIXON
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Alternatively, the contents of this file may be used under the terms of
# the GNU General Public License Version 3 or later (the "GPL"),
# in which case the provisions of the GPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of the GPL, and not to allow others to
# use your version of this file under the terms of Apache License version 2,
# indicate your decision by deleting the provisions above and replace them with
# the notice and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the Apache License version 2 or the GPL.
#
# ***** END LICENSE BLOCK *****
# Clixon pipe example specification
CLICON_MODE="|example_pipe"; # Must start with |
\| {
grep("Search for pattern") <arg:string>, pipe_grep_fn("-e", "arg");
except("Inverted search") <arg:string>, pipe_grep_fn("-v", "arg");
tail("Output last part") <arg:string>, pipe_tail_fn("-n", "arg");
count("Line count"), pipe_wc_fn("-l");
show("Show other format") {
cli("set Input cli syntax"), pipe_showas_fn("cli", true, "set ");
xml("XML"), pipe_showas_fn("xml", true);
json("JSON"), pipe_showas_fn("json");
text("Text curly braces"), pipe_showas_fn("text");
}
# save("Save configuration to file") <filename:string>("Filename (local filename)"), save_config_file("candidate","filename", "xml"); # XXX
}