Boost logo

Boost Users :

Subject: Re: [Boost-users] [Program Options] terminate parsing after first positional argument
From: sjrd (sjrdoeraene_at_[hidden])
Date: 2013-01-22 08:01:28


Hello everyone,

Stuart Pook wrote
> Hello,
>
> How can I tell Boost Program Options to stop parsing the arguments as soon
> as it finds a positional argument?

I was struggling with the same issue, and in the end I found a solution that
does not involve any patch to program_options.
My solution uses the (undocumented but public)
command_line_parser::extra_style_parser() method. You have to define the
following style parser:

and then register it to your instance of command_line_parser with
extra_style_parser. In my code, this yields:

Note that the solution requires you to define the positional arguments with
.positional(), as usual. In fact, the function I showed above mimics the
built-in one that takes care of the '--', with some tweaks.

Cheers,
Sébastien

--
View this message in context: http://boost.2283326.n4.nabble.com/Program-Options-terminate-parsing-after-first-positional-argument-tp4632517p4641656.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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