02-11-2025 02:45 PM
In the NCS man-pages it states:
--------------
Suppresses quoting of non-config elements when displaying them. Newlines will be preserved in strings etc.
Used in J-, I- and C-style CLIs.
The cli-preformatted statement can be used in: leaf, tailf:symlink, and refine.
--------------
but when I use it in a leaf like below:
leaf day0 {
tailf:cli-preformatted;
type string;
}
when entering data into the leaf it always interprets the "\n" into new line instead of preserve it as a text.
anybody ever have this issue?
02-12-2025 08:33 AM
Hi,
Using the tailf:cli-preformatted extension means that the "\n" will be interpreted as a new line instead of preserving it as text.
Let's say I configure the day0 leaf with: hello\nworld
Without the tailf:cli-preformatted extension:
# show running-config day0
day0 "hello\nworld"
With the tailf:cli-preformatted extension:
# show running-config day0
day0 hello
world
02-12-2025 01:30 PM - edited 02-12-2025 01:32 PM
Thanks @cohult
my req is:
EXPECTED
day0 configure terminal
banner exec sequence 1 "####################\r\n*"
banner exec sequence 2 "#" "#\r\n*"
ACTUAL
day0 configure terminal
banner exec sequence 1 "####################\r
*"
banner exec sequence 2 "#" "#\r
*"
is there a way to format it as in EXPECTED?
thanks,
adi
02-13-2025 12:08 AM - edited 02-13-2025 12:17 AM
Please clarify what your configuration is and what is expected to be shown.
Although it seems like you are looking for the tailf:cli-multi-value YANG extension
02-13-2025 12:17 AM
02-13-2025 01:17 AM
container banner {
container exec {
list sequence {
tailf:cli-suppress-mode;
key id;
leaf id {
type uint32;
}
leaf banner {
tailf:cli-drop-node-name;
type string;
}
}
}
}
I get pretty much what you expect:
TOHAGBER-M-V4W1(config)# no banner
TOHAGBER-M-V4W1(config)# banner exec sequence 1 "####################\r\n*"
TOHAGBER-M-V4W1(config)# top
TOHAGBER-M-V4W1(config)# banner exec sequence 2 "\#' '#\r\n*"
TOHAGBER-M-V4W1(config)# commit
TOHAGBER-M-V4W1(config)# do show running-config banner
banner exec sequence 1 "####################\r\n*"
banner exec sequence 2 "\#' '#\r\n*"
Note through if you are going to use double quotes inside a string you either need to escape them with \" or you can maybe use singe quote as per above?
02-13-2025 04:38 PM
thanks for your suggestions cohult and tohagber, but both 'tailf:cli-multi-value' and 'tailf:drop-node-name' don't work for me.
cli-multi-value makes all text to be in one line.
the above drop-node-name need parent and drop the leaf name. I need one leaf like in my EXPECTED above.
02-14-2025 12:50 AM
The intention with drop-node-name is not to give any instruction to the leafs output value when rendered on show command, it just means that the name of the leaf is not showed in C-style cli. My point was mainly if you just have a leaf with simple string type it will render the value as you want AFAIKT. The only thing that does not match what you stated earlier is the double quote inside the value. As i said, if you want a double quote inside an double quoted string, the only way to render that is if it is escaped with \"
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide