Make --regexp required, show help if it is not given.
This commit is contained in:
parent
4b2fbecf93
commit
2ab4705475
|
@ -27,6 +27,7 @@
|
|||
#include <boost/program_options/variables_map.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
@ -61,8 +62,8 @@ po::variables_map parse_options(int argc, char *argv[])
|
|||
("ignore-case,i",
|
||||
translate("Ignore case distinctions in pattern and data.")
|
||||
.str().data())
|
||||
("regexp,e", po::value<std::vector<std::string>>()->composing()
|
||||
->value_name(translate("PATTERN")),
|
||||
("regexp,e", po::value<std::vector<std::string>>()
|
||||
->value_name(translate("PATTERN"))->composing()->required(),
|
||||
translate("Use additional PATTERN for matching.").str().data())
|
||||
;
|
||||
|
||||
|
@ -89,7 +90,15 @@ po::variables_map parse_options(int argc, char *argv[])
|
|||
po::store(po::parse_config_file(configfile, options_visible, true), vm);
|
||||
configfile.close();
|
||||
|
||||
po::notify(vm);
|
||||
try
|
||||
{
|
||||
po::notify(vm);
|
||||
}
|
||||
catch (const boost::program_options::required_option &e)
|
||||
{
|
||||
cout << options_visible;
|
||||
std::rethrow_exception(std::current_exception());
|
||||
}
|
||||
|
||||
if (vm.count("help") != 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user