Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-11-24 02:27:59


Hi Jody, Hi Allen,

Allen Bierbaum wrote:

> Is there any way to tell the program options parser to ignore options
> that it does not recognize? If there is no option like this, how can
> program_options be used with other option parsers?

Jody wrote:

> I am not familiar enough with the library to know the "correct" method.
> The only thing I can think of is that the interface is lacking. I took
> a few minutes to look at the code in
> libs/program_options/src/cmdline.cpp and it looks like the only
> interpretation is empty or a valid option name.

Ok, let me start with a caveat: ignoring unknown options can be ambiguous:

   program --something 10 --known_option

Now, is "10" a value of unknown option or positional option? To remove the
problems all unknown options must use this form:

   --something=10

which may be problem, or may not, depending on your situation. What do you
think?

> So, at this stage, I think it requires an interface change to support
> this option.

The detail::cmdline constructor actually has 'allow_unregisted' parameter,
which is intended to help with this. However, no non-detail interface
allows to specify. Frankly, I don't know if I forgot about this or just
decided to wait for a user to request this feature explicitly.

Adding a new method to the 'common_command_line_parser' to set
'allow_unregistered' flag and then tweaking common_command_line_parser::run
should do the trick? Opinions?

- Volodya


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