|
14 | 14 | import java.util.Collection;
|
15 | 15 | import java.util.List;
|
16 | 16 | import java.util.Optional;
|
| 17 | +import java.util.stream.Stream; |
17 | 18 |
|
| 19 | +import org.apache.commons.lang3.ArrayUtils; |
18 | 20 | import org.apache.logging.log4j.LogManager;
|
19 | 21 | import org.apache.logging.log4j.Logger;
|
20 | 22 | import org.eqasim.core.analysis.DistanceUnit;
|
@@ -152,6 +154,7 @@ public static void main(String[] args) throws CommandLine.ConfigurationException
|
152 | 154 | .allowOptions(CMD_SIMULATE_AFTER)
|
153 | 155 | .allowOptions(CMD_SKIP_SCENARIO_CHECK)
|
154 | 156 | .allowOptions(EQASIM_CONFIGURATOR_CLASS, MODE_CHOICE_CONFIGURATOR_CLASS)
|
| 157 | + .allowAnyOption(true) |
155 | 158 | .build();
|
156 | 159 |
|
157 | 160 | // Loading the config
|
@@ -272,22 +275,28 @@ RecordedTravelTime provideRecordedTravelTime() {
|
272 | 275 | try {
|
273 | 276 | Class<?> runClass = Class.forName(cmd.getOptionStrict(CMD_SIMULATE_AFTER));
|
274 | 277 | Method method = runClass.getMethod("main", String[].class);
|
| 278 | + |
| 279 | + String[] extraArgs = cmd.getAvailableOptions().stream() |
| 280 | + .filter(argName -> argName.startsWith("config:")) |
| 281 | + .filter(argName -> !argName.startsWith("config:standaloneModeChoice")) |
| 282 | + .filter(argName -> !argName.equals("config:plans.inputPlansFile")) |
| 283 | + .flatMap(argName -> Stream.of("--"+argName, cmd.getOption(argName).get())) |
| 284 | + .toArray(String[]::new); |
| 285 | + |
| 286 | + String[] baseArgs = new String[]{ |
| 287 | + "--config-path", cmd.getOptionStrict(CMD_CONFIG_PATH), |
| 288 | + "--config:plans.inputPlansFile", Paths.get(outputDirectoryHierarchy.getOutputFilename("output_plans.xml.gz")).toAbsolutePath().toString(), |
| 289 | + "--config:controler.outputDirectory", outputDirectoryHierarchy.getOutputFilename("sim"), |
| 290 | + "--config:controler.lastIteration", "0" |
| 291 | + }; |
| 292 | + String[] allArgs = ArrayUtils.addAll(baseArgs, extraArgs); |
| 293 | + |
275 | 294 | method.invoke(null, new Object[]{
|
276 |
| - new String[]{ |
277 |
| - "--config-path", cmd.getOptionStrict(CMD_CONFIG_PATH), |
278 |
| - "--config:plans.inputPlansFile", Paths.get(outputDirectoryHierarchy.getOutputFilename("output_plans.xml.gz")).toAbsolutePath().toString(), |
279 |
| - "--config:controler.outputDirectory", outputDirectoryHierarchy.getOutputFilename("sim"), |
280 |
| - "--config:controler.lastIteration", "0" |
281 |
| - } |
| 295 | + allArgs |
282 | 296 | });
|
283 | 297 |
|
284 |
| - } catch (ClassNotFoundException e) { |
285 |
| - throw new RuntimeException(e); |
286 |
| - } catch (InvocationTargetException e) { |
287 |
| - throw new RuntimeException(e); |
288 |
| - } catch (NoSuchMethodException e) { |
289 |
| - throw new RuntimeException(e); |
290 |
| - } catch (IllegalAccessException e) { |
| 298 | + } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | |
| 299 | + IllegalAccessException e) { |
291 | 300 | throw new RuntimeException(e);
|
292 | 301 | }
|
293 | 302 | }
|
|
0 commit comments