Boost logo

Boost Users :

From: Ian McCulloch (ianmcc_at_[hidden])
Date: 2006-08-16 22:14:25


Harsh Deshmane wrote:

> Hi,
>
> Multiple occurrences are definitely allowed and handled.
>
> If you do specify the option value to populate a container,
> and then pass the containerpointer to the add_options() method,
> you can later iterate over the options.

[...]

Sorry, I should have been clearer. I know how to do multiple occurances of
options that require a value, what I want though is multiple occurances of
a switch. A single switch can be done with something like

desc.add_options()
   ("verbose,v", bool_switch(), "increase verbosity");

but this fails with a multiple_occurrences exception if more than one -v
option is supplied.

Multiple boolean options can be done with something like

desc.add_options()
   ("verbose,v", value<std::vector<bool> >(), "increase verbosity");

but this requires that each option is given a value, such as

$ myprogram -v true -v true -v true

which is not what I want. I want instead to be able to use a command line
like

$ myprogram -v -v -v

Cheers,
Ian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net