Boost logo

Boost :

From: Jonathan Graehl (jonathan_at_[hidden])
Date: 2004-09-14 16:21:29

Jonathan Graehl wrote:

> I used to do this:
>>>bool help_flag;
>>> ("help,h","produce help message");
> Now this is better:
>>bool help_flag;
>> ("help,h", bool_switch(&help_flag),"produce help message");
> I tried it, and it works, but the usage string is a little odd:
> -h [ --help ] arg (=0) : produce help message
> -v [ --version ] arg (=0) : print the version number

Apologies for self-reply:

It turns out that the "optional" nature of the argument to a bool_switch
creates an impossible situation when positional arguments are used. For

myprogram -h positional_argument

will try to parse positional_argument as a bool if I use a bool_switch
for the -h option

This seems like fairly useless behavior; bool_switch should *never*
expect any argument (or, I should say, I'd like a version that doesn't
consume my positional parameters).

Also, in parsers.cpp,

throw too_many_positional_options_error(
                            "too much positional options");

should be "too many positional options".


Boost list run by bdawes at, gregod at, cpdaniel at, john at