Boost logo

Boost Users :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2006-01-09 04:15:40


Marshall Clow wrote:

>>The simplest way for this to work is to define a single bool option
>>"rtti". Then, use custom parsers to translate "frtti" and "fno_rtti" to
>>"rtti=off" and "rtti=on" respectively. See
>>http://boost.org/doc/html/program_options/howto.html#id2715843
>>which discusses exactly this "no" prefix handling. As a side effect users
>>will be able to specity "--rtti=on", but maybe that's not a big problem.
>
> Ok - I can see how that works, but I think I chose a bad example.
> Here's a different one:
>
> My program has three reporting "modes":
> Normal -- print out some stuff
> Quiet -- print nothing
> Verbose -- print lots of stuff.
>
>
> I need to respond to switches like "--quiet" and "--verbose", which is
> fine, but I more than one of them in the same command line is an error.
>
> I can certainly check in my code to see if more than one was
> presented (and I will do that); I am just surprised that this
> functionality is not part of the program-options library.
>
> Maybe in a future version. ;-)

Maybe. If you look at libs/program_options/example/real.cpp you'll see that
I expected conflicting options to be handled by defining a function
'conflicting_options' and using it as appropriate.

That still seems a good interface for me. Say:

   conflicting_options(vm, "normal", "quiet", "verbose");

is not worse IMO then:

   desc.conflicting_options()
        ("normal", "quiet", "verbose");

or any other syntax I can invent. It might be reasonable to expect such
"conflicting_option" function to be part of library, though.

- Volodya


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