[quagga-dev 8518] Re: adding optional arguments to quagga commands

G. Paul Ziemba pz-quagga-dev at ziemba.us
Wed Feb 16 19:40:21 GMT 2011


tak.official at gmail.com (takCoder) writes:

>i am trying to add a command to quagga which needs to have optional input
>arguments. but i can't find a proper way to do so...

>for example, if the goal command is "date" and the input arguments are "day
><1-31>" and "month <1-12>", i need a way of implementation that makes the
>user able to enter any of the forms below:
>1)#date
>2)#date day <1-31>
>3)#date month <1-12>
>4)#date day <1-31> month <1-12>
>5)#date month <1-12> day <1-31>

>i check the present code but found no sample..

>i was wondering whether or not there is a way to write one Defun for the
>whole commands, which has the needed optional arguments separated or marked
>in way that make them really optional...

The current favorite approach (see, for example, bgpd/bgp_vty.c)
seems to be to define the first variant with DEFUN and include
code there to parse the argument variations; then define the other
variants with ALIAS.

If you search for "no_bgp_router_id" there is a simple example
with one optional argument.
-- 
G. Paul Ziemba
FreeBSD unix:
11:36AM  up 24 days, 10:54, 24 users, load averages: 0.08, 0.13, 0.15



More information about the Quagga-dev mailing list