Boost logo

Boost Users :

Subject: Re: [Boost-users] [Program Options] terminate parsing after first positional argument
From: Olaf Meeuwissen (olaf.meeuwissen_at_[hidden])
Date: 2012-07-06 03:45:57


Following with interest from the side lines ...

driscoll_at_[hidden] writes:

> 3. Implement this via a different mechanism. There *is* a bit of
> precedence for this with the parser's allow_unregistered() function [2],
> which sets a flag in the parser somewhere and eventually it works its way
> down where it's checked from the cmdline::finish_option function [3].
>
> However, we still have to decide on the API. It shouldn't just be
> cmdline::allow_interspersed() like allow_unregistered(), because
> interspersed arguments will already be allowed. So it could either take a
> boolean, and then I'd call it like 'command_line_parser(argc,
> argv).allow_interspersed(false).run()', or we could call it
> disabled_interspersed().
>
> (A reasonable choice but even more inconsistent with the other style
> options than #2 was, and I like that one more. allow_interspersed has more
> in common with the other style_t flags than it does with
> allow_unregistered(), and the new API wouldn't even exactly mirror
> allow_unregistered() anyway unless that were changed as well.)

Interspersed options/arguments are unregistered, aren't they? Unless I
misunderstood, the only thing you want to change is what happens when
you encounter the first unregistered option/argument. Why not let that
member function accept a flag (defaulting to false for backward
compatibility) that controls that?

What allow_unregistered() does now is in effect move every registered
option before the first unregistered one. AFAIU, this is what you don't
want, right? When the parser sees the first unregistered option it can
just stop parsing. Right now, it seems to be going out of its way to
find more recognizable options.

Hope this helps,

-- 
Olaf Meeuwissen, LPIC-2           FLOSS Engineer -- AVASYS CORPORATION
FSF Associate Member #1962               Help support software freedom
                 http://www.fsf.org/jf?referrer=1962

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