Use ArgumentParser::parseArgsOrExit()
This commit is contained in:
parent
868f0fd2bd
commit
aeb097a549
|
@ -29,7 +29,7 @@ set(META_VERSION_PATCH 3)
|
|||
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||
|
||||
# find c++utilities
|
||||
find_package(c++utilities 4.0.0 REQUIRED)
|
||||
find_package(c++utilities 4.10.0 REQUIRED)
|
||||
use_cpp_utilities()
|
||||
|
||||
# include modules to apply configuration
|
||||
|
|
6
main.cpp
6
main.cpp
|
@ -23,7 +23,6 @@ SystemForLocations outputSystemForLocations = SystemForLocations::LatitudeLongit
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
try {
|
||||
SET_APPLICATION_INFO;
|
||||
|
||||
ArgumentParser argparser;
|
||||
|
@ -104,7 +103,7 @@ int main(int argc, char *argv[])
|
|||
Argument version("version", 'v', "Shows the version of this application.");
|
||||
argparser.setMainArguments({ &help, &convert, &distance, &trackLength, &bearing, &fbearing, &midpoint, &destination, &gmapsLink,
|
||||
&inputAngularMeasureArg, &outputFormForAnglesArg, &inputSystemForLocationsArg, &outputSystemForLocationsArg, &version });
|
||||
argparser.parseArgs(argc, argv);
|
||||
argparser.parseArgsOrExit(argc, argv);
|
||||
|
||||
if (inputAngularMeasureArg.isPresent()) {
|
||||
const char *inputFormat = inputAngularMeasureArg.values().front();
|
||||
|
@ -192,9 +191,6 @@ int main(int argc, char *argv[])
|
|||
cerr << endl;
|
||||
printAngleFormatInfo(cerr);
|
||||
}
|
||||
} catch (const Failure &ex) {
|
||||
cerr << "Unable to parse arguments. " << ex.what() << endl << "See --help for available commands.";
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue