positional arguments in boost::program_options

Hi, I'm writing a program which will run other programs (think xargs) and I have the following question. If I am reading the docs right, I get positional arguments by doing something like 1) Make a "normal" argument --arg 2) Tell it that positional arguments map to --arg However, if I do this, that means that if someone runs my_wrapper target_program --arg a then the --arg "disappears" because boost::po treats it as an actual option and not a positional argument. I can (mostly) get around this by naming all the fake positional arguments something like --ZZZZarg and assuming no one will ever want to pass that to another program, but it's a bit unsatisfactory conceptually. Is there a better way? Evan

On 06/13/2012 05:12 PM, Evan Driscoll wrote:
I can (mostly) get around this by naming all the fake positional arguments something like --ZZZZarg and assuming no one will ever want to pass that to another program, but it's a bit unsatisfactory conceptually. Is there a better way?
Actually, playing around more, it's not even acceptable: something like my_wrapper target_program --help will trigger my wrapper's --help option. And I definitely *do* want that and perhaps some other options that could potentially conflict. Is there a way to get the behavior I want with Boost or am I out of luck? Evan

On 13 June 2012 23:23, Evan Driscoll
On 06/13/2012 05:12 PM, Evan Driscoll wrote:
I can (mostly) get around this by naming all the fake positional arguments something like --ZZZZarg and assuming no one will ever want to pass that to another program, but it's a bit unsatisfactory conceptually. Is there a better way?
Actually, playing around more, it's not even acceptable: something like
my_wrapper target_program --help
will trigger my wrapper's --help option. And I definitely *do* want that and perhaps some other options that could potentially conflict.
Is there a way to get the behavior I want with Boost or am I out of luck?
I haven't got back to this issue since I noticed, but it may be related to this: https://svn.boost.org/trac/boost/ticket/5201 http://stackoverflow.com/questions/4107087/accepting-negative-doubles-with-b... If it is, then it needs AFAIU some not-so-non-intrusive refactoring within the boost::program_options. Best regards, -- Mateusz Loskot, http://mateusz.loskot.net

On 06/13/2012 05:23 PM, Evan Driscoll wrote:
Actually, playing around more, it's not even acceptable: something like
my_wrapper target_program --help
will trigger my wrapper's --help option. And I definitely *do* want that and perhaps some other options that could potentially conflict.
Is there a way to get the behavior I want with Boost or am I out of luck?
After figuring out that a couple other C++ CLI-parsing libraries didn't do what I want either, I patched Boost and filed a feature request. Both can be found here: https://svn.boost.org/trac/boost/ticket/6991 Evan
participants (2)
-
Evan Driscoll
-
Mateusz Loskot