所以我在开发人员方面需要的是
addoption("-use-something", "Use Something instead of Some other thing", localVarName, desiredValue, defauultValue);
在用户方面,我希望看到3件事
start my.exe -use-something
)答案 0 :(得分:2)
答案 1 :(得分:1)
您应该使用Boost.Program_options。 tutorial的示例:
// Declare the supported options.
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level")
;
po::variables_map vm;
po::store(po::parse_command_line(ac, av, desc), vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << "\n";
return 1;
}
if (vm.count("compression")) {
cout << "Compression level was set to "
<< vm["compression"].as<int>() << ".\n";
} else {
cout << "Compression level was not set.\n";
}