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