Not necessarily the best example in the world but the following works for me:
using namespace boost::program_options;namespace po = boost::program_options;const int style(command_line_style::default_style +command_line_style::allow_long_disguise +command_line_style::allow_dash_for_short);po::variables_map vm;vector<string> unreg;//-----------------------------------------------------------------------------// Set up options//-----------------------------------------------------------------------------po::options_description desc("Allowed options");desc.add_options()("help,h", "produce help message")("input-file,i", po::value<vector<string> >(), "input file")("debug,d", po::value<string>(), "debug")("noupdates,x", po::value<string>(), "no updates");//-----------------------------------------------------------------------------// Parse the command line//-----------------------------------------------------------------------------parsed_options parsed = command_line_parser(argc,argv).style(style).options(desc).allow_unregistered().run();unreg = collect_unrecognized(parsed.options,include_positional);po::store(parsed, vm);po::notify(vm);Much of the style stuff is documented only if you wade through code. unreg will contain the unrecognized items.LarryFrom: Michael PowellSent: Friday, April 12, 2013 4:03 PMSubject: [Boost-users] program_options allow_unregistered and *nix styleHello,
I would like to find a way to allow_unregistered program_options, as well as specify cls::unix_style ^ cls::allow_short, where cls is po::command_line_style.The code I've got here doesn't seem to like unrecognized ones://vis_ are my visible options, vars_ is my variable map.po::store(parse_command_line(argc, argv, vis_,
cls::unix_style ^ cls::allow_short), vars_);
po::notify(vars_);And then a slight variation with apparently a way to do this (untested), how to specify that cls?
//http://stackoverflow.com/questions/10178525/how-to-handle-unsolicited-parameters-in-boostprogram-options
po::parsed_options parsed_ = po::command_line_parser(argc, argv)
.options(vis_).allow_unregistered().run();Possible? Thank ye...
Regards,
Michael Powell
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users