mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-11 05:45:36 -06:00
Merge pull request #1677 from joakim-hove/version
Add special case handling of commandline argument "--version"
This commit is contained in:
commit
eeb17b460f
@ -132,6 +132,13 @@ opm_add_test(flow
|
||||
flow/flow_ebos_oilwater_polymer.cpp)
|
||||
install(TARGETS flow DESTINATION bin)
|
||||
|
||||
add_test(NAME flow__version
|
||||
COMMAND flow --version)
|
||||
set_tests_properties(flow__version PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "${${project}_LABEL}")
|
||||
|
||||
|
||||
|
||||
include(OpmBashCompletion)
|
||||
opm_add_bash_completion(flow)
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp>
|
||||
#include <opm/autodiff/FlowMainEbos.hpp>
|
||||
#include <opm/autodiff/moduleVersion.hpp>
|
||||
#include <ewoms/common/propertysystem.hh>
|
||||
#include <ewoms/common/parametersystem.hh>
|
||||
#include <opm/autodiff/MissingFeatures.hpp>
|
||||
@ -83,12 +84,31 @@ namespace detail
|
||||
|
||||
throw std::invalid_argument( "Cannot find input case " + casename );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This function is an extreme special case, if the program has been invoked
|
||||
// *exactly* as:
|
||||
//
|
||||
// flow --version
|
||||
//
|
||||
// the call is intercepted by this function which will print "flow $version"
|
||||
// on stdout and exit(0).
|
||||
void handleVersionCmdLine(int argc, char** argv) {
|
||||
if (argc != 2)
|
||||
return;
|
||||
|
||||
if (std::strcmp(argv[1], "--version") == 0) {
|
||||
std::cout << "flow " << Opm::moduleVersionName() << std::endl;
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ----------------- Main program -----------------
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
detail::handleVersionCmdLine(argc, argv);
|
||||
// MPI setup.
|
||||
#if HAVE_DUNE_FEM
|
||||
Dune::Fem::MPIManager::initialize(argc, argv);
|
||||
|
Loading…
Reference in New Issue
Block a user