Skip to content

Commit

Permalink
fix merging of default arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Feb 10, 2024
1 parent 6321844 commit edabc86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public static boolean isRunFromDesktop() {

// check if gui was explicitly enabled
String env = System.getenv().getOrDefault("RUN_GUI", "false");
if (env.equalsIgnoreCase("true") || env.equals("1") )
if (env.equalsIgnoreCase("true") || env.equals("1"))
return true;

String property = System.getProperty("RUN_GUI", "false");
if (property.equalsIgnoreCase("true") || property.equals("1") )
if (property.equalsIgnoreCase("true") || property.equals("1"))
return true;

String macIdentifier = System.getenv().getOrDefault("__CFBundleIdentifier", "none");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,25 @@ public static void runWithDefaults(Class<? extends MATSimApplication> clazz, Str
} else {
// run if no other command is present
if (args.length > 0) {
// valid command is present
if (args[0].equals("run") || args[0].equals("prepare") || args[0].equals("analysis") || args[0].equals("gui") ){
// valid command is present
} else
// If this is a run command, the default args can be applied
if (args[0].equals("run"))
args = ApplicationUtils.mergeArgs(args, defaultArgs);

} else {
// Automatically add run command
args = ApplicationUtils.mergeArgs(new String[]{"run"}, defaultArgs);
String[] runArgs = ApplicationUtils.mergeArgs(new String[]{"run"}, defaultArgs);
args = ApplicationUtils.mergeArgs(defaultArgs, runArgs);
}

} else
// Automatically add run command
args = ApplicationUtils.mergeArgs(new String[]{"run"}, defaultArgs);

run(clazz, ApplicationUtils.mergeArgs(args, defaultArgs));
log.info("Running {} with: {}", clazz.getSimpleName(), String.join(" ", args));

run(clazz, args);
}
}

Expand Down

0 comments on commit edabc86

Please sign in to comment.