Boost logo

Boost Users :

From: Marshall Clow (marshall_at_[hidden])
Date: 2005-12-21 09:56:32


At 10:11 AM +0300 12/20/05, Vladimir Prus wrote:
>Marshall Clow wrote:
>
>> I'm trying to use boost::program_options for the first time, and
>> there's a couple things that I am tripping over.
>>
>> The first is the idea of mutually exclusive options. I can't find any
>> support for them in the library, and that surprises me - to the point
>> of asking for help.
>>
>> I have two options, only one of which can be specified; say -frtti
>> and -fno_rtti (say).
>
>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. ;-)

Thanks for the response!

-- 
-- Marshall
Marshall Clow     Idio Software   <mailto:marshall_at_[hidden]>
It is by caffeine alone I set my mind in motion.
It is by the beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.

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