2017-08-29 02:38:41 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-01-16 04:52:06 -06:00
|
|
|
//
|
2017-08-29 02:38:41 -05:00
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2019-01-16 04:52:06 -06:00
|
|
|
//
|
2017-08-29 02:38:41 -05:00
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
2019-01-16 04:52:06 -06:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-08-29 02:38:41 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RiaArgumentParser.h"
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RiaBaseDefs.h"
|
2018-03-08 03:10:15 -06:00
|
|
|
#include "RiaImportEclipseCaseTools.h"
|
2019-02-21 06:13:04 -06:00
|
|
|
#include "RiaLogging.h"
|
2018-03-08 03:10:15 -06:00
|
|
|
#include "RiaPreferences.h"
|
|
|
|
#include "RiaProjectModifier.h"
|
|
|
|
#include "RiaRegressionTestRunner.h"
|
2017-08-29 02:38:41 -05:00
|
|
|
|
|
|
|
#include "RimProject.h"
|
|
|
|
|
|
|
|
#include "RiuMainWindow.h"
|
2018-04-26 23:28:08 -05:00
|
|
|
#include "RiuPlotMainWindow.h"
|
2017-08-29 02:38:41 -05:00
|
|
|
|
|
|
|
#include "RicfCommandFileExecutor.h"
|
2019-01-16 04:52:06 -06:00
|
|
|
#include "RicfMessages.h"
|
2017-08-29 02:38:41 -05:00
|
|
|
|
|
|
|
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
|
|
|
|
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
|
2019-01-16 04:52:06 -06:00
|
|
|
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
|
2019-01-16 05:50:57 -06:00
|
|
|
#include "RicImportSummaryCasesFeature.h"
|
2017-08-29 02:38:41 -05:00
|
|
|
|
|
|
|
#include "cvfProgramOptions.h"
|
|
|
|
#include "cvfqtUtils.h"
|
|
|
|
|
|
|
|
#include "cafUtils.h"
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QFile>
|
2019-01-16 04:52:06 -06:00
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
2017-08-29 02:38:41 -05:00
|
|
|
|
2019-05-06 03:36:05 -05:00
|
|
|
|
2017-08-29 02:38:41 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-16 04:52:06 -06:00
|
|
|
///
|
2017-08-29 02:38:41 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-05-06 03:36:05 -05:00
|
|
|
bool RiaArgumentParser::parseArguments(cvf::ProgramOptions* progOpt)
|
2017-08-29 02:38:41 -05:00
|
|
|
{
|
2019-05-06 03:36:05 -05:00
|
|
|
CVF_ASSERT(progOpt);
|
2019-05-20 06:21:02 -05:00
|
|
|
progOpt->registerOption("grpcserver", "[<portnumber>]", "Run as a GRPC server. Default port is 50051", cvf::ProgramOptions::SINGLE_VALUE);
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->registerOption("console", "", "Run as a console application without Graphics");
|
|
|
|
progOpt->registerOption("last", "", "Open last used project.");
|
|
|
|
progOpt->registerOption("project", "<filename>", "Open project file <filename>.", cvf::ProgramOptions::SINGLE_VALUE);
|
|
|
|
progOpt->registerOption("case",
|
2019-05-03 00:49:53 -05:00
|
|
|
"<case name without extension or filename>",
|
|
|
|
"If case or grid filename, import simulation grid data. If summary file name, import summary data",
|
2019-01-16 04:52:06 -06:00
|
|
|
cvf::ProgramOptions::MULTI_VALUE);
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->registerOption("startdir", "<folder>", "Set startup directory.", cvf::ProgramOptions::SINGLE_VALUE);
|
|
|
|
progOpt->registerOption("savesnapshots",
|
2019-01-16 04:52:06 -06:00
|
|
|
"all|views|plots",
|
|
|
|
"Save snapshot of all views or plots to project file location sub folder 'snapshots'. Option 'all' "
|
|
|
|
"will include both views and plots. Application closes after snapshots have been written.",
|
|
|
|
cvf::ProgramOptions::OPTIONAL_MULTI_VALUE);
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->registerOption(
|
2019-01-16 04:52:06 -06:00
|
|
|
"size", "<width> <height>", "Set size of the main application window.", cvf::ProgramOptions::MULTI_VALUE);
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->registerOption(
|
2019-01-16 04:52:06 -06:00
|
|
|
"replaceCase",
|
|
|
|
"[<caseId>] <newGridFile>",
|
|
|
|
"Replace grid in <caseId> or first case with <newgridFile>. Repeat parameter for multiple replace operations.",
|
|
|
|
cvf::ProgramOptions::MULTI_VALUE,
|
|
|
|
cvf::ProgramOptions::COMBINE_REPEATED);
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->registerOption("replaceSourceCases",
|
2019-01-16 04:52:06 -06:00
|
|
|
"[<caseGroupId>] <gridListFile>",
|
|
|
|
"Replace source cases in <caseGroupId> or first grid case group with the grid files listed in the "
|
|
|
|
"<gridListFile> file. Repeat parameter for multiple replace operations.",
|
|
|
|
cvf::ProgramOptions::MULTI_VALUE,
|
|
|
|
cvf::ProgramOptions::COMBINE_REPEATED);
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->registerOption("replacePropertiesFolder",
|
2019-01-16 04:52:06 -06:00
|
|
|
"[<caseId>] <newPropertiesFolder>",
|
|
|
|
"Replace the folder containing property files for an eclipse input case.",
|
|
|
|
cvf::ProgramOptions::MULTI_VALUE);
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->registerOption("multiCaseSnapshots",
|
2019-01-16 04:52:06 -06:00
|
|
|
"<gridListFile>",
|
|
|
|
"For each grid file listed in the <gridListFile> file, replace the first case in the project and save "
|
|
|
|
"snapshot of all views.",
|
|
|
|
cvf::ProgramOptions::SINGLE_VALUE);
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->registerOption("commandFile", "<commandfile>", "Execute the command file.", cvf::ProgramOptions::SINGLE_VALUE);
|
|
|
|
progOpt->registerOption(
|
2019-01-16 04:52:06 -06:00
|
|
|
"commandFileProject",
|
|
|
|
"<filename>",
|
|
|
|
"Project to use if performing case looping for command file. Used in conjunction with 'commandFileReplaceCases'.",
|
|
|
|
cvf::ProgramOptions::SINGLE_VALUE);
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->registerOption("commandFileReplaceCases",
|
2019-01-16 04:52:06 -06:00
|
|
|
"[<caseId>] <caseListFile>",
|
|
|
|
"Supply list of cases to replace in project, performing command file for each case.",
|
|
|
|
cvf::ProgramOptions::SINGLE_VALUE);
|
2019-08-08 03:45:02 -05:00
|
|
|
progOpt->registerOption("help", "", "Displays help text and exits.");
|
|
|
|
progOpt->registerOption("?", "", "Displays help text and exits.");
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->registerOption("regressiontest", "<folder>", "System command", cvf::ProgramOptions::SINGLE_VALUE);
|
|
|
|
progOpt->registerOption("updateregressiontestbase", "<folder>", "System command", cvf::ProgramOptions::SINGLE_VALUE);
|
2019-05-06 05:46:44 -05:00
|
|
|
#ifdef USE_UNIT_TESTS
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->registerOption("unittest", "", "System command");
|
2019-05-06 05:46:44 -05:00
|
|
|
#endif
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->registerOption("ignoreArgs", "", "Ignore all arguments. Mostly for testing purposes");
|
2017-08-29 02:38:41 -05:00
|
|
|
|
2019-05-06 03:36:05 -05:00
|
|
|
progOpt->setOptionPrefix(cvf::ProgramOptions::DOUBLE_DASH);
|
2017-08-29 02:38:41 -05:00
|
|
|
|
|
|
|
QStringList arguments = QCoreApplication::arguments();
|
2019-05-06 03:36:05 -05:00
|
|
|
|
|
|
|
bool parseOk = progOpt->parse(cvfqt::Utils::toStringVector(arguments));
|
2017-08-29 02:38:41 -05:00
|
|
|
|
|
|
|
// If positional parameter functionality is to be supported, the test for existence of positionalParameters must be removed
|
|
|
|
// This is based on a pull request by @andlaus https://github.com/OPM/ResInsight/pull/162
|
2019-08-08 03:45:02 -05:00
|
|
|
if (!parseOk || !progOpt->positionalParameters().empty())
|
2017-08-29 02:38:41 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|