Skip to content

Commit 13a0bb4

Browse files
committed
Accept multiple input file parameters
1 parent c5a2ec1 commit 13a0bb4

File tree

7 files changed

+52
-40
lines changed

7 files changed

+52
-40
lines changed

src/Core/Application/Tests/ApplicationTests.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2012 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -50,7 +50,7 @@ TEST(ApplicationSingletonTest, CanCreateAndParseCommandLine)
5050
appParams = app.parameters();
5151
ASSERT_TRUE(appParams.get() != nullptr);
5252

53-
EXPECT_EQ("network.srn5", appParams->inputFile().get());
53+
EXPECT_EQ("network.srn5", appParams->inputFiles()[0]);
5454
EXPECT_TRUE(appParams->executeNetwork());
5555
}
5656

@@ -95,4 +95,4 @@ TEST(ApplicationTest, GetUserDesktopDirectory)
9595
std::cout << desktop << std::endl;
9696
}
9797

98-
#endif
98+
#endif

src/Core/Command/GlobalCommandBuilderFromCommandLine.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ using namespace SCIRun::Core::Commands;
6262

6363
if (!params->disableSplash() && !params->disableGui())
6464
q->enqueue(cmdFactory_->create(ShowSplashScreen));
65-
65+
6666
if (!params->disableGui())
6767
q->enqueue(cmdFactory_->create(ShowMainWindow));
6868
else
6969
std::cout << "HEADLESS MODE" << std::endl; /// @todo obviously
7070

7171
if (params->dataDirectory())
7272
q->enqueue(cmdFactory_->create(SetupDataDirectory));
73-
74-
if (params->inputFile())
73+
74+
if (!params->inputFiles().empty())
7575
q->enqueue(cmdFactory_->create(LoadNetworkFile));
7676
else if (params->pythonScriptFile())
7777
q->enqueue(cmdFactory_->create(RunPythonScript));

src/Core/CommandLine/CommandLine.cc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2012 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -57,14 +57,14 @@ class CommandLineParserInternal
5757
("logfile,l", po::value<std::string>(), "add output messages to a logfile--TODO")
5858
("interactive,i", "interactive mode--TODO")
5959
("headless,x", "disable GUI (Qt still needed, for now)")
60-
("input-file", po::value<std::string>(), "SCIRun Network Input File")
60+
("input-file", po::value<std::vector<std::string>>(), "SCIRun Network Input File")
6161
("script,s", po::value<std::string>(), "SCIRun Python Script")
6262
("no_splash", "Turn off splash screen")
6363
("verbose", "Turn on debug log information")
6464
("threadMode", po::value<std::string>(), "network execution threading mode--DEVELOPER USE ONLY")
6565
("reexecuteMode", po::value<std::string>(), "network reexecution mode--DEVELOPER USE ONLY")
6666
;
67-
67+
6868
positional_.add("input-file", -1);
6969
}
7070

@@ -91,7 +91,7 @@ class CommandLineParserInternal
9191
ostr << desc_;
9292
return ostr.str();
9393
}
94-
94+
9595
private:
9696
po::options_description desc_;
9797
po::positional_options_description positional_;
@@ -116,30 +116,30 @@ class ApplicationParametersImpl : public ApplicationParameters
116116
bool isRegressionMode,
117117
bool isVerboseMode) : help_(help), version_(version), executeNetwork_(executeNetwork),
118118
executeNetworkAndQuit_(executeNetworkAndQuit), disableGui_(disableGui),
119-
disableSplash_(disableSplash), isRegressionMode_(isRegressionMode), isVerboseMode_(isVerboseMode)
119+
disableSplash_(disableSplash), isRegressionMode_(isRegressionMode), isVerboseMode_(isVerboseMode)
120120
{}
121121
bool help_, version_, executeNetwork_, executeNetworkAndQuit_, disableGui_, disableSplash_, isRegressionMode_, isVerboseMode_;
122122
};
123123
ApplicationParametersImpl(
124124
const std::string& entireCommandLine,
125-
const boost::optional<std::string>& inputFile,
125+
std::vector<std::string>&& inputFiles,
126126
const boost::optional<boost::filesystem::path>& pythonScriptFile,
127127
const boost::optional<boost::filesystem::path>& dataDirectory,
128128
const boost::optional<std::string>& threadMode,
129129
const boost::optional<std::string>& reexecuteMode,
130130
const Flags& flags
131131
) : entireCommandLine_(entireCommandLine),
132-
inputFile_(inputFile), pythonScriptFile_(pythonScriptFile), dataDirectory_(dataDirectory),
132+
inputFiles_(inputFiles), pythonScriptFile_(pythonScriptFile), dataDirectory_(dataDirectory),
133133
threadMode_(threadMode), reexecuteMode_(reexecuteMode),
134134
flags_(flags)
135135
{}
136136

137-
virtual boost::optional<std::string> inputFile() const
137+
virtual const std::vector<std::string>& inputFiles() const
138138
{
139-
return inputFile_;
139+
return inputFiles_;
140140
}
141141

142-
virtual boost::optional<boost::filesystem::path> pythonScriptFile() const
142+
virtual boost::optional<boost::filesystem::path> pythonScriptFile() const
143143
{
144144
return pythonScriptFile_;
145145
}
@@ -173,7 +173,7 @@ class ApplicationParametersImpl : public ApplicationParameters
173173
{
174174
return flags_.disableGui_;
175175
}
176-
176+
177177
virtual bool disableSplash() const
178178
{
179179
return flags_.disableSplash_;
@@ -199,14 +199,14 @@ class ApplicationParametersImpl : public ApplicationParameters
199199
return reexecuteMode_;
200200
}
201201

202-
virtual const std::string& entireCommandLine() const
202+
virtual const std::string& entireCommandLine() const
203203
{
204204
return entireCommandLine_;
205205
}
206206

207207
private:
208208
std::string entireCommandLine_;
209-
boost::optional<std::string> inputFile_;
209+
std::vector<std::string> inputFiles_;
210210
boost::optional<boost::filesystem::path> pythonScriptFile_;
211211
boost::optional<boost::filesystem::path> dataDirectory_;
212212
boost::optional<std::string> threadMode_, reexecuteMode_;
@@ -230,7 +230,7 @@ ApplicationParametersHandle CommandLineParser::parse(int argc, const char* argv[
230230
{
231231
auto parsed = impl_->parse(argc, argv);
232232
std::vector<std::string> cmdline(argv, argv + argc);
233-
auto inputFile = parsed.count("input-file") != 0 ? parsed["input-file"].as<std::string>() : boost::optional<std::string>();
233+
auto inputFiles = parsed.count("input-file") != 0 ? parsed["input-file"].as<std::vector<std::string>>() : std::vector<std::string>();
234234
auto pythonScriptFile = boost::optional<boost::filesystem::path>();
235235
if (parsed.count("script") != 0 && !parsed["script"].empty() && !parsed["script"].defaulted())
236236
{
@@ -245,7 +245,7 @@ ApplicationParametersHandle CommandLineParser::parse(int argc, const char* argv[
245245
auto reexecuteMode = parsed.count("reexecuteMode") != 0 ? parsed["reexecuteMode"].as<std::string>() : boost::optional<std::string>();
246246
return boost::make_shared<ApplicationParametersImpl>
247247
(boost::algorithm::join(cmdline, " "),
248-
inputFile,
248+
std::move(inputFiles),
249249
pythonScriptFile,
250250
dataDirectory,
251251
threadMode,

src/Core/CommandLine/CommandLine.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2012 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -27,7 +27,7 @@
2727
*/
2828

2929
#ifndef CORE_COMMANDLINE_COMMANDLINESPEC_H
30-
#define CORE_COMMANDLINE_COMMANDLINESPEC_H
30+
#define CORE_COMMANDLINE_COMMANDLINESPEC_H
3131

3232
#include <string>
3333
#include <boost/filesystem.hpp>
@@ -44,7 +44,7 @@ namespace SCIRun {
4444
{
4545
public:
4646
virtual ~ApplicationParameters();
47-
virtual boost::optional<std::string> inputFile() const = 0;
47+
virtual const std::vector<std::string>& inputFiles() const = 0;
4848
virtual boost::optional<boost::filesystem::path> pythonScriptFile() const = 0;
4949
virtual boost::optional<boost::filesystem::path> dataDirectory() const = 0;
5050
virtual bool help() const = 0;
@@ -76,4 +76,4 @@ namespace SCIRun {
7676

7777
}}}
7878

79-
#endif
79+
#endif

src/Core/CommandLine/Tests/ScirunCommandLineSpecTests.cc

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2012 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -35,7 +35,7 @@ TEST(ScirunCommandLineSpecTest, CanReadBasicOptions)
3535
{
3636
CommandLineParser parser;
3737

38-
const std::string expectedHelp =
38+
const std::string expectedHelp =
3939
"SCIRun5 basic options:\n"
4040
" -h [ --help ] prints usage information\n"
4141
" -v [ --version ] prints out version information\n"
@@ -53,17 +53,17 @@ TEST(ScirunCommandLineSpecTest, CanReadBasicOptions)
5353
" --verbose Turn on debug log information\n"
5454
" --threadMode arg network execution threading mode--DEVELOPER USE ONLY\n"
5555
" --reexecuteMode arg network reexecution mode--DEVELOPER USE ONLY\n";
56-
56+
5757
EXPECT_EQ(expectedHelp, parser.describe());
58-
58+
5959
{
6060
const char* argv[] = {"scirun.exe", "--help", "net.srn5"};
6161
int argc = sizeof(argv)/sizeof(char*);
6262

6363
ApplicationParametersHandle aph = parser.parse(argc, argv);
6464

6565
EXPECT_TRUE(aph->help());
66-
EXPECT_EQ("net.srn5", aph->inputFile().get());
66+
EXPECT_EQ("net.srn5", aph->inputFiles()[0]);
6767
}
6868

6969
{
@@ -73,7 +73,7 @@ TEST(ScirunCommandLineSpecTest, CanReadBasicOptions)
7373
ApplicationParametersHandle aph = parser.parse(argc, argv);
7474

7575
EXPECT_TRUE(aph->help());
76-
EXPECT_EQ("net.srn5", aph->inputFile().get());
76+
EXPECT_EQ("net.srn5", aph->inputFiles()[0]);
7777
}
7878

7979
{
@@ -84,7 +84,7 @@ TEST(ScirunCommandLineSpecTest, CanReadBasicOptions)
8484

8585
EXPECT_TRUE(aph->version());
8686
EXPECT_FALSE(aph->help());
87-
EXPECT_FALSE(aph->inputFile());
87+
EXPECT_TRUE(aph->inputFiles().empty());
8888
}
8989

9090
{
@@ -95,7 +95,7 @@ TEST(ScirunCommandLineSpecTest, CanReadBasicOptions)
9595

9696
EXPECT_TRUE(aph->version());
9797
EXPECT_FALSE(aph->help());
98-
EXPECT_FALSE(aph->inputFile());
98+
EXPECT_TRUE(aph->inputFiles().empty());
9999
}
100100

101101
{
@@ -106,7 +106,19 @@ TEST(ScirunCommandLineSpecTest, CanReadBasicOptions)
106106

107107
EXPECT_FALSE(aph->help());
108108
EXPECT_TRUE(aph->executeNetwork());
109-
EXPECT_EQ("net.srn5", aph->inputFile().get());
109+
EXPECT_EQ("net.srn5", aph->inputFiles()[0]);
110+
}
111+
112+
{
113+
const char* argv[] = {"scirun.exe", "-e", "net1.srn5", "net2.srn5"};
114+
int argc = sizeof(argv)/sizeof(char*);
115+
116+
ApplicationParametersHandle aph = parser.parse(argc, argv);
117+
118+
EXPECT_FALSE(aph->help());
119+
EXPECT_TRUE(aph->executeNetwork());
120+
EXPECT_EQ("net1.srn5", aph->inputFiles()[0]);
121+
EXPECT_EQ("net2.srn5", aph->inputFiles()[1]);
110122
}
111123

112124
{
@@ -118,7 +130,7 @@ TEST(ScirunCommandLineSpecTest, CanReadBasicOptions)
118130
EXPECT_FALSE(aph->help());
119131
EXPECT_TRUE(aph->executeNetworkAndQuit());
120132
EXPECT_FALSE(aph->executeNetwork());
121-
EXPECT_EQ("net.srn5", aph->inputFile().get());
133+
EXPECT_EQ("net.srn5", aph->inputFiles()[0]);
122134
}
123135

124136
{

src/Core/ConsoleApplication/ConsoleCommands.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ using namespace SCIRun::Dataflow::Networks;
4040

4141
bool LoadFileCommandConsole::execute()
4242
{
43-
auto inputFile = Application::Instance().parameters()->inputFile();
44-
if (inputFile)
43+
auto inputFiles = Application::Instance().parameters()->inputFiles();
44+
if (!inputFiles.empty())
4545
{
46-
auto filename = *inputFile;
46+
auto filename = inputFiles[0];
4747

4848
/// @todo: real logger
4949
std::cout << "Attempting load of " + filename << std::endl;

src/Interface/Application/GuiCommands.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ using namespace SCIRun::Dataflow::Networks;
4949

5050
bool LoadFileCommandGui::execute()
5151
{
52-
auto inputFile = Application::Instance().parameters()->inputFile();
53-
return SCIRunMainWindow::Instance()->loadNetworkFile(QString::fromStdString(inputFile.get()));
52+
auto inputFiles = Application::Instance().parameters()->inputFiles();
53+
return SCIRunMainWindow::Instance()->loadNetworkFile(QString::fromStdString(inputFiles[0]));
5454
}
5555

5656
bool ExecuteCurrentNetworkCommandGui::execute()

0 commit comments

Comments
 (0)