multi option for params

20 views
Skip to first unread message

Mohammad RafatPanah

unread,
Apr 20, 2025, 3:13:21 AMApr 20
to klish
Hi guys,

As we progress in developing our product using klish, we find some features that can be helpful.
Sometimes you need to add a parameter several times but don't have any limit on the number of entered parameters, but at least you must enter it once. For example, we want to add a description param, and the user can enter description values with spaces. Or some flags like verbose can be handled based on number of 'v's entered.

Is there any multi option for params?
Something like this:
<PARAM name="number-list" help="number" optional="true" ptype="UINT" multi="true"/>
Can you help me to add it into klish code?

Thanks

Serj Kalichev

unread,
Apr 21, 2025, 3:52:06 AMApr 21
to kl...@googlegroups.com
Hi

klish version 3 has such parameters
Thanks --
You received this message because you are subscribed to the Google Groups "klish" group.
To unsubscribe from this group and stop receiving emails from it, send an email to klish+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/klish/070be322-7841-4d01-8920-bd6cf10256cfn%40googlegroups.com.


Mohammad RafatPanah

unread,
May 5, 2025, 9:59:18 AMMay 5
to klish

Hi Serj,

Thank you very much for your previous responses and the time you took to help me!

I’m now facing another, somewhat similar issue.
We’re trying to save multiple instances of a single command in the config file using <CONFIG operation="set" .../>, but each time we use it, the previous entry gets overwritten.

Is there a way to handle this properly in klish?

Once again, I really appreciate your accurate and prompt support.

Dmitry Kasyanov

unread,
May 5, 2025, 10:44:13 AMMay 5
to kl...@googlegroups.com

<COMMAND name="source"
  help="source interface "
  mode="subcommand"
  ptype="SUBCOMMAND">
  <PARAM name="port"
    help="ethernet port"
    ptype="PORT_NUMBER"/>
  <CONFIG pattern="^${__line}$"/>
  <ACTION buitin="clish_nop"/>
</COMMAND>

(config)# source 1
(config)# source 2
(config)# source 3
(config)# do show running-config
source 1
source 2
source 3


The pattern field shows what part of the string will be compared when replacing. If there is a ${__line} variable there, if the line does not completely match the previous one, a new one will be added. Another option is to write pattern="^source ${port}$"

С уважением,
Дмитрий Касьянов.


пн, 5 мая 2025 г. в 16:59, Mohammad RafatPanah <m.rafat...@gmail.com>:

Mohammad RafatPanah

unread,
May 6, 2025, 3:28:33 AMMay 6
to klish
Thanks in advance! This resolves my problem.
Reply all
Reply to author
Forward
0 new messages