ConfD User Community

How to make optional parameters in a .cli


#1

I’m actualy configure my .cli and i looking to have a cmd name ‘test-cli’ with 4 parameters added in any order.
I’m looking also to make my parameters optional.

localhost>test-cli param1 param2 param3 param4
or
localhost>test-cli param2
or
localhost>test-cli param4 param 1 param 3
or
localhost>test-cli param2 param4

didn’t works i got an error

localhost>test-cli param2 ?
% Invalid input detected at ‘^’ marker.


#2

Are param1, param2, etc. just example values or are they keywords?


#3

In my dot cli i declare my param1 or param2 like that, there is maybe an other way but i don’t find it.

             <param>
          <info/>
           <type>
             <enums>param1</enums>
           </type>
           <params>
             <param>
             <param>
          <info/>
           <type>
             <enums>param2</enums>
           </type>
           <params>
             <param>

#4

There are two options. You can make all params optional with choice attribute (see description /clispec/$MODE/cmd/params in the ConfD User Guide - clispec section):

<params mode="choice" min="0" max="1">

or with optional sub-element (see /clispec/$MODE/cmd/params/param/optional):

<param>
    <type>
        <simpleType name="ipv4Prefix" namespace="http://tail-f.com/ns/confd/1.0"/>
    </type>    
    <optional/>
</param>

The pasted example seems to be too short, it is not clear where params (top and nested ones) start and end.