|
Boost Users : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2006-05-19 02:25:15
Santosh Joseph wrote:
> Code snippet is below...basically I have 2 options I
> want to process "host,s" & "help,h".
> I would like to process options like this:
> for host: --host, -host, -s
> for help: --help, -help, -h
> Maybe I setup the opt_style variable wrong or is this
> correct behavior?
> I'm using boost 1.33.1
>
> when i run the program:
>> po.exe -host localhost -h
> *** Command line processing error: ambiguous option h
.....
int opt_style =
(po::command_line_style::unix_style |
po::command_line_style::allow_long_disguise |
po::command_line_style::allow_slash_for_short);
The important points here are that
1. 'unix_style' includes 'allow_guessing'
2. you explicitly specify allow_long_disguise
So, when program_options sees '-h' it first tries to parse it as
long option, and due to 'allow_guessing' it checks for all long options
starting with 'h'. There are two such options, so you get an ambiguity.
If we first tried to parse every token as short option, then -help will be
parsed as option -h with value 'elp' -- probably not what you want.
I'd suggest that you mask out the allow_guessing style option.
- Volodya
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