-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathRiaArgumentParser.cpp
More file actions
161 lines (136 loc) · 8.98 KB
/
Copy pathRiaArgumentParser.cpp
File metadata and controls
161 lines (136 loc) · 8.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// 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.
//
// 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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaArgumentParser.h"
#include "RiaBaseDefs.h"
#include "RiaImportEclipseCaseTools.h"
#include "RiaLogging.h"
#include "RiaProjectModifier.h"
#include "RiaRegressionTestRunner.h"
#include "RimProject.h"
#include "RiuMainWindow.h"
#include "RiuPlotMainWindow.h"
#include "RicfCommandFileExecutor.h"
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
#include "RicImportSummaryCasesFeature.h"
#include "cafPdmScriptIOMessages.h"
#include "cvfProgramOptions.h"
#include "cvfqtUtils.h"
#include "cafUtils.h"
#include <QCoreApplication>
#include <QFile>
#include <QString>
#include <QStringList>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaArgumentParser::parseArguments( cvf::ProgramOptions* progOpt )
{
CVF_ASSERT( progOpt );
progOpt->registerOption( "help", "", "Displays help text and exits." );
progOpt->registerOption( "?", "", "Displays help text and exits." );
progOpt->registerOption( "preferences", "<filename>", "Import Preferences from <filename>.", cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "project", "<filename>", "Open project file <filename>.", cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "last", "", "Open last used project." );
progOpt->registerOption( "case",
"<casename|filename> [<casename|filename> ...]",
"Imports the Eclipse cases specified by case name with or without extension."
"If <casename>, import the corresponding grid file and summary file"
"If <filename> has extension .GRRID/.EGRID, import the grid file and corresponding "
"summary file"
"If <filename> has extension .SMSPEC, import the summary file (does not open the "
"corresponding grid file)",
cvf::ProgramOptions::MULTI_VALUE );
progOpt->registerOption( "size", "<width> <height>", "Set size of the main application window.", cvf::ProgramOptions::MULTI_VALUE );
progOpt->registerOption( "console", "", "Launch as a console application without graphics" );
progOpt->registerOption( "server", "[<portnumber>]", "Launch as a GRPC server. Default port is 50051", cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "portnumberfile", "[<filename>]", "Write the port number to this file.", cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "threadcount", "<threadcount>", "Set number of threads for parallel processing.\n", cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "startdir", "<folder>", "Set startup directory.\n", cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "summaryplot",
"[<plotOptions>] <eclipsesummaryvectors> <eclipsedatafiles>",
"Creates a summary plot using all the <eclipsedatafiles>,"
"and all the summary vectors defined in <eclipsesummaryvectors>."
"Use --summaryplot -help to show a more detailed help text.\n",
cvf::ProgramOptions::OPTIONAL_MULTI_VALUE );
progOpt->registerOption( "commandFile", "<commandfile>", "Execute the command file.", cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "commandFileReplaceCases",
"[<caseId>] <caseListFile>",
"Supply list of cases to replace in project, performing command file for each case.",
cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "commandFileProject",
"<filename>",
"Project to use if performing case looping for command file. Used in conjunction with "
"'commandFileReplaceCases'.\n",
cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "snapshotsize", "<width> <height>", "Set size of exported snapshot images.", cvf::ProgramOptions::MULTI_VALUE );
progOpt->registerOption( "snapshotfolder",
"<folder>",
"Set the destination folder for exported snapshot images.\n",
cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "savesnapshots",
"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 );
progOpt->registerOption( "multiCaseSnapshots",
"<gridListFile>",
"For each grid file listed in the <gridListFile> file, replace the first case in the "
"project and save "
"snapshots of all views.\n",
cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "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 );
progOpt->registerOption( "replaceSourceCases",
"[<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 );
progOpt->registerOption( "replacePropertiesFolder",
"[<caseId>] <newPropertiesFolder>",
"Replace the folder containing property files for an eclipse input case.\n",
cvf::ProgramOptions::MULTI_VALUE );
progOpt->registerOption( "updateregressiontestbase", "<folder>", "System command", cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "regressiontest", "<folder>", "System command", cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "generate", "[<outputFile>]", "Generate code or documentation", cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "ignoreArgs", "", "System command. Ignore all arguments. Mostly for testing purposes" );
progOpt->registerOption( "version", "", "Display the application version string" );
progOpt->registerOption( "openplotwindow", "", "Open the 2D plot window. By default, the 3D window is displayed." );
progOpt->registerOption( "egridReader",
"<readerName>",
"Select the reader type used to access EGRID files, valid values are RESDATA or OPM_COMMON",
cvf::ProgramOptions::SINGLE_VALUE );
progOpt->registerOption( "loglevel",
"<level>",
"Set the log level. Valid values are DISABLED, ERROR, WARNING, INFO, DEBUG",
cvf::ProgramOptions::SINGLE_VALUE );
progOpt->setOptionPrefix( cvf::ProgramOptions::DOUBLE_DASH );
QStringList arguments = QCoreApplication::arguments();
bool parseOk = progOpt->parse( cvfqt::Utils::toStringVector( arguments ) );
// 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
return parseOk && progOpt->positionalParameters().empty();
}