
I am using boost::program_options and found a problem with passing a series of positive/negative numbers. i.e myProgram.out --system 0 -2 2 -3 Similar problem like in: http://stackoverflow.com/questions/4107087/accepting-negative-doubles-with-b... I do not want to disable short options. I want to make quotes working. So when I call myProgram.out --system '0 -2' error: in option 'system': invalid option value myProgram.out --system 0 -2 error: unknown option -2 What quotation do you mean ? I am using bash, on CYGWIN and in linux Let me know your answer. Regards Andrzej.

On 03/02/11 13:31, Andrzej Zielinski wrote:
I am using boost::program_options and found a problem with passing a series of positive/negative numbers. i.e myProgram.out --system 0 -2 2 -3
Similar problem like in: http://stackoverflow.com/questions/4107087/accepting-negative-doubles-with-b... I do not want to disable short options. I want to make quotes working.
So when I call
myProgram.out --system '0 -2' error: in option 'system': invalid option value
A couple of months ago, I discussed it quickly with Volodya on the #boost IRC channel and here is a short recipe of how it could be solved: #################################################################### Nov 10 17:04:17 <mloskot> volodya: I think it's feasible to refactor the loops in the cmdline parser to handle multitoken options with negative numbers as values. I have an idea to add ::multitoken(int exact_tokens_num) and make parser consuming as much values as the exact number of tokens specified, regardless how the options look like Nov 10 17:04:26 <mloskot> volodya: what you think about this idea? Nov 10 17:05:30 <volodya> mloskot: well, I think that if that translates into min and max number of tokesn of the option being equal to that value, it seems sane Nov 10 17:05:53 <mloskot> volodya: yes, basically that would be the thing Nov 10 17:05:55 <volodya> and of course, when min=max, there's no need to guessing. Nov 10 17:05:59 <volodya> ok, sounds good. #################################################################### It's not a big problem, just lack of man power to solve. I suppose program_options would welcome relevant patches. Best regards, -- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org Member of ACCU, http://accu.org

On 04/02/11 09:39, Mateusz Loskot wrote:
On 03/02/11 13:31, Andrzej Zielinski wrote:
I am using boost::program_options and found a problem with passing a series of positive/negative numbers. i.e myProgram.out --system 0 -2 2 -3
Similar problem like in: http://stackoverflow.com/questions/4107087/accepting-negative-doubles-with-b...
I do not want to disable short options. I want to make quotes working.
So when I call
myProgram.out --system '0 -2' error: in option 'system': invalid option value
A couple of months ago, I discussed it quickly with Volodya on the #boost IRC channel and here is a short recipe of how it could be solved:
#################################################################### Nov 10 17:04:17 <mloskot> volodya: I think it's feasible to refactor the loops in the cmdline parser to handle multitoken options with negative numbers as values. I have an idea to add ::multitoken(int exact_tokens_num) and make parser consuming as much values as the exact number of tokens specified, regardless how the options look like
Nov 10 17:04:26 <mloskot> volodya: what you think about this idea?
Nov 10 17:05:30 <volodya> mloskot: well, I think that if that translates into min and max number of tokesn of the option being equal to that value, it seems sane
Nov 10 17:05:53 <mloskot> volodya: yes, basically that would be the thing
Nov 10 17:05:55 <volodya> and of course, when min=max, there's no need to guessing.
Nov 10 17:05:59 <volodya> ok, sounds good. ####################################################################
It's not a big problem, just lack of man power to solve. I suppose program_options would welcome relevant patches.
FYI, I have reported it as ticket so it wont be forgotten: https://svn.boost.org/trac/boost/ticket/5201 Best regards, -- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org Member of ACCU, http://accu.org
participants (2)
-
Andrzej Zielinski
-
Mateusz Loskot