Opened 14 years ago
Closed 13 years ago
#2577 closed Bugs (fixed)
ambigous program options
Reported by: | Owned by: | Vladimir Prus | |
---|---|---|---|
Milestone: | To Be Determined | Component: | program_options |
Version: | Boost 1.34.1 | Severity: | Regression |
Keywords: | Cc: |
Description
Basically a variation of this regression: http://lists.boost.org/Archives/boost/2006/01/98811.php
To trigger it again you have to slightly modify the test case:
# include <iostream> # include <boost/program_options.hpp> int main(int argc, char * argv[]) try { using namespace boost::program_options; options_description desc("Options"); desc.add_options() ("foo", "foo") ("foobar", "foobar") ("foo-bar", "foo-bar") ("barbar", "barbar") ("bar-bar", "bar-bar") ("bar", "bar") ; parsed_options parsed = parse_command_line(argc, argv, desc); variables_map vm; store(parsed, vm); notify(vm); std::cerr << vm.count("foo") << std::endl; std::cerr << vm.count("foobar") << std::endl; std::cerr << vm.count("foo-bar") << std::endl; std::cerr << vm.count("bar") << std::endl; std::cerr << vm.count("barbar") << std::endl; std::cerr << vm.count("bar-bar") << std::endl; } catch (std::exception & ex) { std::cerr << argv[0] << ": " << ex.what() << std::endl; return EXIT_FAILURE; }
$ ./a.out --foo 1 0 0 0 0 0
$ ./a.out --bar ./a.out: ambiguous option bar
Btw, wouldn't it make more sense, if boost program_options would do its ambiguity checking as part of add_options()? I mean before the actual parsing step ...
PS: Take a look at: https://svn.boost.org/trac/boost/ticket/545 I get there:
Oops… Trac detected an internal error: TypeError: a float is required
}}}
Note:
See TracTickets
for help on using tickets.
This problem does not happen in SVN HEAD.