From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-09-27 01:28:21
Michael van der Westhuizen wrote:
> Vladimir Prus wrote:
>> Jonathan Graehl wrote:
>>>I grepped through the program_options source and couldn't find anything
>>>about declaratively specifying required options (or even more
>>>specifically, min/max # of occurrences), except for positional options.
>> Does "min/max" number of occurrences makes much sense? In variables_map,
>> an option is either present, or not, it cannot be present twice.
> Yes, it does make sense. Two examples I can think of offhand are tcpdump
> and nmap, both of which allow you to specify the -v flag multiple times
> to increase verbosity.
That's multiple occurences of a value on the command line. But in
variables_map, the option will be present only once -- supposedly, the
number of "-v" occurences will be the value of the option.
This is just like -I (include path) option. It can be specified several
times, but end up as a vector of paths.
I think that Jonathan was more interested in "option is required to be
present in variables_map" functionality.
On a related note, I don't think adding min/max number of occurences for
command line is a good idea. That would make interface harder, and is only
reasonable for most contrived command lines, and it's possible to enforce
this restriction by manipulating parsed_options instance directly.
The idea to require some option to be present in variables_map seems
reasonable -- it's more common case.