Boost Users :
Subject: Re: [Boost-users] [program_options] Limited multitoken
From: Brad Jensen (bradley.jensen_at_[hidden])
Date: 2012-02-04 17:59:33
Thank you for your response. You have convinced me that allowing
positional arguments after a multitoken is a bad idea, and so the
Boost program_options library will work for my program.
On Fri, Jan 20, 2012 at 8:03 AM, Dmitriy Matison <matison.d_at_[hidden]> wrote:
> Hello, Brad:
> What processing is done by your own parsing function?
> Positional options after multitoken options are bad practice in
> general. It's not an obvious and flexible approach. Imagine one of
> your options changes tokens count, Â all users off your program will be
> confused using their old command lines. If you like positionals, maybe
> it's a workaround to use three positional values since your -j tokens
> count is fixed? Multitoken options are commonly used in cases when you
> have a variable length list of inputs, i.e. files.
> If -j is optional, you can place it's values as positional after your
> current positional option in your invocation scheme.
> On 20/01/2012, Bradley Jensen <bradley.jensen_at_[hidden]> wrote:
>> I'm working on a personal project. Everything works using my own options
>> processing function, but I am having a hard time implementing one specific
>> aspect of my option processing code using the Boost program_options library.
>> My program has a flag (-j) which takes in two doubles as arguments.
>> Currently, I can invoke my program like so:
>> ./foo -j 1.0 2.0 3
>> where 3 is treated like a positional.
>> Because the -j option must consume several tokens, it seemed natural that I
>> should use multitoken, like so:
>> vector<double> v;
>> po::options_description desc("Allowed options");
>> Â Â ("jingle,j", po::value<vector<double> >(&v)->multitoken(), "Test thing");
>> But this causes positional arguments to get eaten up and added to v when -j
>> is the last flag option. So, in my example, v would contain 1.0, 2.0, and
>> 3.0. I suppose I am looking for some way to indicate that the -j flag
>> consumes exactly two tokens.
>> I've looked over the documentation on the Boost website, but I couldn't find
>> anything about this. Any help would be greatly appreciated.
>> Boost-users mailing list
> Ð¡ ÑÐ²Ð°Ð¶ÐµÐ½Ð¸ÐµÐ¼,
> ÐÐ°ÑÐ¸ÑÐ¾Ð½ ÐÐ¼Ð¸ÑÑÐ¸Ð¹.
> Boost-users mailing list
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