|
Boost Users : |
Subject: [Boost-users] [Options Description] positional_options_description throw exception
From: Sakharuk, Vladimir (vladimir.sakharuk_at_[hidden])
Date: 2010-03-24 11:54:14
Trying to access positional arguments with sample program bellow:
If I run: "a.out one"
Error: unknown option positional
Same error I got on "a.out -h one" and "a.out one -h"
If I run: "a.out one two"
Error: too many positional options
But "a.out -h works"
Thanks \/.
namespace po=boost::program_options;
po::options_description cmds("Options");
cmds.add_options()
("help,h", "output help message");
po::positional_options_description positional;
positional.add("positional", 1);
po::variables_map vm;
po::parsed_options parsed = po::command_line_parser(argc,
argv).options(cmds).positional(positional).run();
po::store( parsed, vm);
po::notify(vm);
if (vm.count("help")) {
cout << cmds << endl;
return 0;
}
if(vm.count("positional") ) {
cout << "positional";
}
}
catch(const std::exception& ex) {
cout << "Error: " << ex.what() << endl;
}
===============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
===============================================================================
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