#11392 closed Bugs (fixed)
boost::program_options accepting switch-options that match the beginning of defined option, but is not full option typed out.
Reported by: | Owned by: | Vladimir Prus | |
---|---|---|---|
Milestone: | To Be Determined | Component: | program_options |
Version: | Boost 1.57.0 | Severity: | Problem |
Keywords: | Cc: |
Description
With:
namespace po = boost::program_options; po::options_description desc ("options"); desc.add_options ()
( "help,h", "print this help message") ( "config,c", po::value<ustring>(), "config file, default: $XDG_CONFIG_HOME/astroid/config") ( "new-config,n", "make new default config, then exit") ( "mailto,m", po::value<ustring>(), "compose mail with mailto url or address") ( "no-auto-poll", "do not poll automatically");
po::variables_map vm;
bool show_help = false;
try {
po::store ( po::parse_command_line (argc, argv, desc), vm );
} catch (po::unknown_option &ex) {
cout << "unknown option" << endl; cout << ex.what() << endl; show_help = true;
}
running:
./program --asdf
fails, but running:
./program --hel
is parsed as --help.
Change History (5)
comment:1 by , 7 years ago
Component: | None → program_options |
---|---|
Owner: | set to |
comment:2 by , 7 years ago
comment:3 by , 7 years ago
Oh, darn. Didn't realize it was configurable. Thanks for the explanation!
gaute
comment:4 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Good that this turned to be easy to solve!
comment:3 by , 7 years ago
Oh, darn. Didn't realize it was configurable. Thanks for the explanation!
gaute
Thanks for the report!
Why do you believe this to be a bug? The default_style, defined in cmdline.hpp, does include "allow_guessing" bit, so it appears the library behaves as designed.