Skip to content

Commit

Permalink
Update Main.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Germief committed May 8, 2021
1 parent d947d58 commit 67617cd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/simulator/launcher/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ public class Main {
private final static String _forceLawsDefaultValue = "nlug";
private final static String _stateComparatorDefaultValue = "epseq";


// some attributes to stores values corresponding to command-line parameters
//
private static String mode = "batch";
private static Double _dtime = null;
private static String _inFile = null;
private static String _outFile = null;
Expand Down Expand Up @@ -89,6 +91,7 @@ private static void parseArgs(String[] args) {
CommandLine line = parser.parse(cmdLineOptions, args);

parseHelpOption(line, cmdLineOptions);
parseModeOption(line);
parseInFileOption(line);
// TODO add support of -o, -eo, and -s (define corresponding parse methods)
parseStepsOption(line);
Expand Down Expand Up @@ -162,6 +165,10 @@ private static Options buildOptions() {
+ factoryPossibleValues(_stateComparatorFactory) + ". Default value: '"
+ _stateComparatorDefaultValue + "'.")
.build());

cmdLineOptions.addOption(Option.builder("m").longOpt("mode").hasArg()
.desc("Execution Mode. Possible values: ’batch’(Batch mode), ’gui’ (Graphical UserInterface mode). Default value: ’batch’.").build());

return cmdLineOptions;
}

Expand All @@ -180,6 +187,11 @@ public static String factoryPossibleValues(Factory<?> factory) {
s = s + ". You can provide the 'data' json attaching :{...} to the tag, but without spaces.";
return s;
}

private static void parseModeOption(CommandLine line) throws ParseException{
mode = line.getOptionValue("m");

}

private static void parseHelpOption(CommandLine line, Options cmdLineOptions) {
if (line.hasOption("h")) {
Expand All @@ -191,7 +203,7 @@ private static void parseHelpOption(CommandLine line, Options cmdLineOptions) {

private static void parseInFileOption(CommandLine line) throws ParseException {
_inFile = line.getOptionValue("i");
if (_inFile == null) {
if (_inFile == null && mode.equals("batch")) {
throw new ParseException("In batch mode an input file of bodies is required");
}
}
Expand Down

0 comments on commit 67617cd

Please sign in to comment.