#282 abort when no argument #652
1 changed files with 15 additions and 7 deletions
|
|
@ -86,16 +86,24 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
bpo::variables_map options;
|
bpo::variables_map options;
|
||||||
|
|
||||||
bpo::parsed_options po = bpo::command_line_parser(argc, argv).options(opts).allow_unregistered().run();
|
try
|
||||||
std::vector<std::string> unrecognized = bpo::collect_unrecognized(po.options, bpo::include_positional);
|
{
|
||||||
if (unrecognized.size() > 0) {
|
bpo::parsed_options po = bpo::command_line_parser(argc, argv).options(opts).allow_unregistered().run();
|
||||||
std::cout << "Unknown parameter(s): " << std::endl;
|
std::vector<std::string> unrecognized = bpo::collect_unrecognized(po.options, bpo::include_positional);
|
||||||
for (auto s : unrecognized) {
|
if (unrecognized.size() > 0) {
|
||||||
std::cout << " " << s << std::endl;
|
std::cout << "Unknown parameter(s): " << std::endl;
|
||||||
|
for (auto s : unrecognized) {
|
||||||
|
std::cout << " " << s << std::endl;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
bpo::store(po, options);
|
||||||
|
}
|
||||||
|
catch (const boost::program_options::invalid_command_line_syntax & e)
|
||||||
|
{
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
bpo::store(po, options);
|
|
||||||
|
|
||||||
if (options.count("help")) {
|
if (options.count("help")) {
|
||||||
std::cout << opts << "\n";
|
std::cout << opts << "\n";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue