X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2Fargparser%2FArgParser.java;h=b300c67ec52d8a0d9631d5044dd0de532be13a0d;hb=b8b5965ecce656c11042aabcda9dca342f320e65;hp=41189b8f2b3846ed8484c302ee4a3ae67522e9a4;hpb=fdb954823b553478208fc3a4a27fe7189c220bff;p=jalview.git diff --git a/src/jalview/bin/argparser/ArgParser.java b/src/jalview/bin/argparser/ArgParser.java index 41189b8..b300c67 100644 --- a/src/jalview/bin/argparser/ArgParser.java +++ b/src/jalview/bin/argparser/ArgParser.java @@ -37,6 +37,7 @@ import java.util.Map; import jalview.bin.Cache; import jalview.bin.Console; import jalview.bin.Jalview; +import jalview.bin.Jalview.ExitCode; import jalview.bin.argparser.Arg.Opt; import jalview.bin.argparser.Arg.Type; import jalview.util.FileUtils; @@ -171,6 +172,15 @@ public class ArgParser private BootstrapArgs bootstrapArgs = null; + private boolean oldArguments = false; + + private boolean mixedArguments = false; + + /** + * saved examples of mixed arguments + */ + private String[] mixedExamples = new String[] { null, null }; + static { argMap = new HashMap<>(); @@ -235,19 +245,39 @@ public class ArgParser if (arg.startsWith(DOUBLEDASH)) { dd = true; - break; + if (mixedExamples[1] == null) + { + mixedExamples[1] = arg; + } } else if (arg.startsWith("-") || arg.equals("open")) { d = true; + if (mixedExamples[0] == null) + { + mixedExamples[0] = arg; + } + } + } + if (d) + { + if (dd) + { + mixedArguments = true; + } + else + { + oldArguments = true; } } - if (d && !dd) + + if (oldArguments || mixedArguments) { // leave it to the old style -- parse an empty list parse(new ArrayList(), false, false); return; } + if (bsa != null) this.bootstrapArgs = bsa; else @@ -373,10 +403,12 @@ public class ArgParser { // arg not found Console.error("Argument '" + arg + "' not recognised. Exiting."); - Jalview.exit("Invalid argument used." + System.lineSeparator() - + "Use" + System.lineSeparator() + "jalview " - + Arg.HELP.argString() + System.lineSeparator() - + "for a usage statement.", 13); + Jalview.exit( + "Invalid argument used." + System.lineSeparator() + "Use" + + System.lineSeparator() + "jalview " + + Arg.HELP.argString() + System.lineSeparator() + + "for a usage statement.", + ExitCode.INVALID_ARGUMENT); continue; } if (a.hasOption(Opt.PRIVATE) && !allowPrivate) @@ -892,7 +924,7 @@ public class ArgParser { String message = Arg.ARGFILE.argString() + EQUALS + "\"" + argFile.getPath() + "\": File does not exist."; - Jalview.exit(message, 2); + Jalview.exit(message, ExitCode.FILE_NOT_FOUND); } try { @@ -906,7 +938,7 @@ public class ArgParser { String message = Arg.ARGFILE.argString() + "=\"" + argFile.getPath() + "\": File could not be read."; - Jalview.exit(message, 3); + Jalview.exit(message, ExitCode.FILE_NOT_READABLE); } } // Third param "true" uses Opt.PRIVATE args --setargile=argfile and @@ -932,7 +964,7 @@ public class ArgParser String message = Arg.ARGFILE.argString() + "=\"" + argFile.getPath() + "\": File could not be read."; Console.debug(message, e); - Jalview.exit(message, 3); + Jalview.exit(message, ExitCode.FILE_NOT_READABLE); } } return args; @@ -1320,4 +1352,18 @@ public class ArgParser return linkedArgs.get(linkedId); } + public boolean isOldStyle() + { + return oldArguments; + } + + public boolean isMixedStyle() + { + return mixedArguments; + } + + public String[] getMixedExamples() + { + return mixedExamples; + } } \ No newline at end of file