|
Boost Users : |
Subject: [Boost-users] Program Options: Omit positional arguments from help
From: Florian Lindner (mailinglists_at_[hidden])
Date: 2015-10-28 10:07:58
Hello,
I have this piece of code:
void getOptions(int argc, char *argv[])
{
namespace po = boost::program_options;
po::options_description desc("Artificial testing tool.");
desc.add_options()
("help", "produce help")
("participant", po::value<std::string>(), "Participant Name");
po::positional_options_description pd;
pd.add("participant", 1);
po::variables_map vm;
//po::store(po::parse_command_line(argc, argv, desc), vm);
po::store(po::command_line_parser(argc,
argv).options(desc).positional(pd).run(), vm);
po::notify(vm);
if (vm.count("help")) {
std::cout << desc << std::endl;
return;
}
}
First question: Is the usage of po::store correct that way? I've found it
somehwere on the internet but the documentation mentions no alternative
parser call when using positional arguments.
Main question: When using help it still displays --participant, albeit it's
only a placeholder for the positional argument. Is there a way to hide a
options or what is the correct way?
Thanks,
Florian
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