Use Algorithm to Locate '--version' Option

This commit is contained in:
Bård Skaflestad 2021-10-07 15:20:36 +02:00
parent fca167acfd
commit ad74de2e1a

View File

@ -509,15 +509,19 @@ namespace Opm
// //
// the call is intercepted by this function which will print "flow $version" // the call is intercepted by this function which will print "flow $version"
// on stdout and exit(0). // on stdout and exit(0).
void handleVersionCmdLine_(int argc, char** argv) { void handleVersionCmdLine_(int argc, char** argv)
for ( int i = 1; i < argc; ++i )
{ {
if (std::strcmp(argv[i], "--version") == 0) { auto pos = std::find_if(argv, argv + argc,
[](const char* arg)
{
return std::strcmp(arg, "--version") == 0;
});
if (pos != argv + argc) {
std::cout << "flow " << moduleVersionName() << std::endl; std::cout << "flow " << moduleVersionName() << std::endl;
std::exit(EXIT_SUCCESS); std::exit(EXIT_SUCCESS);
} }
} }
}
#ifndef FLOW_BLACKOIL_ONLY #ifndef FLOW_BLACKOIL_ONLY
int runTwoPhase(const Phases& phases) int runTwoPhase(const Phases& phases)