Boost logo

Boost :

Subject: Re: [boost] [program_options] Feature request for untyped variables
From: Dave Johnson (not_enough_spam_at_[hidden])
Date: 2009-11-17 13:25:55


Sascha wrote:

> I think I managed to do what you want with implicit_value(). Implicit
> value is the value which will be applied if not additional token is
> followed by the option on command line:
> ...
> Anyhow, implicit_value is not described in documentation and this is
> already mentioned in Ticket#1132
> (https://svn.boost.org/trac/boost/ticket/1132)

The ticket is about the zero_tokens feature, which seems to be exactly what I need. I tried it out with boost 1.33.1 and it worked fine.

        ("help" , po::value<bool>(&Options.help)->zero_tokens(),
"produce help message")
        ("verbose" , po::value<bool>(&Options.verbose)->zero_tokens(),
"create more detailed output")

The command
./my_app --verbose --help
seemed to set both flags and I did not need to use vm.count() to access the flag state.

-Dave

      


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk