X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fbin%2Fargparser%2FBootstrapArgs.java;h=d32a5b29f1ef394754ff71b8d5a928aee929e897;hb=61c5b7072f14e1328bde5b5bf896affd3eb5a626;hp=e1ad1d71c3afc7451a71a36cd761c0de6cf19f5e;hpb=d6e308f41ea1bc57434911e47ac01a19f76e8895;p=jalview.git diff --git a/src/jalview/bin/argparser/BootstrapArgs.java b/src/jalview/bin/argparser/BootstrapArgs.java index e1ad1d7..d32a5b2 100644 --- a/src/jalview/bin/argparser/BootstrapArgs.java +++ b/src/jalview/bin/argparser/BootstrapArgs.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -27,6 +28,8 @@ public class BootstrapArgs private Set argsTypes = new HashSet<>(); + private boolean outputToStdout = false; + public static BootstrapArgs getBootstrapArgs(String[] args) { List argList = new ArrayList<>(Arrays.asList(args)); @@ -52,7 +55,7 @@ public class BootstrapArgs { if (argFiles.contains(inArgFile)) { - System.err.println( + jalview.bin.Console.errPrintln( "Looped argfiles detected: '" + inArgFile.getPath() + "'"); return; } @@ -108,9 +111,22 @@ public class BootstrapArgs } } - if (ArgParser.argMap.containsKey(argName) && val == null) + // after all other args, look for Opt.PREFIX args if still not found + if (!ArgParser.argMap.containsKey(argName)) { - val = "true"; + for (Arg potentialArg : EnumSet.allOf(Arg.class)) + { + if (potentialArg.hasOption(Opt.PREFIXKEV) && argName != null + && argName.startsWith(potentialArg.getName()) + && val != null) + { + val = argName.substring(potentialArg.getName().length()) + + ArgParser.EQUALS + val; + argName = argName.substring(0, + potentialArg.getName().length()); + break; + } + } } Arg a = ArgParser.argMap.get(argName); @@ -133,7 +149,27 @@ public class BootstrapArgs if (a == null || !a.hasOption(Opt.BOOTSTRAP)) { - // not a valid bootstrap arg + // not a bootstrap arg + + // make a check for an output going to stdout + if (a != null && a.hasOption(Opt.OUTPUTFILE) + && a.hasOption(Opt.STDOUT)) + { + if (val == null && i + 1 < args.size()) + { + val = args.get(i + 1); + } + if (val.startsWith("[") && val.indexOf(']') > 0) + { + val = val.substring(val.indexOf(']') + 1); + } + + if (ArgParser.STDOUTFILENAME.equals(val)) + { + this.outputToStdout = true; + } + } + continue; } @@ -169,6 +205,11 @@ public class BootstrapArgs } else { + if (val == null) + { + val = "true"; + } + add(a, type, val); } } @@ -251,7 +292,7 @@ public class BootstrapArgs private void add(Arg a, Type t, String s) { List> l = getOrCreateList(a); - if (a.hasOption(Opt.MULTI) || l.size() == 0) + if (a.hasOption(Opt.MULTIVALUE) || l.size() == 0) { l.add(entry(t, s)); } @@ -260,7 +301,7 @@ public class BootstrapArgs private void addAll(Arg a, Type t, List al) { List> l = getOrCreateList(a); - if (a.hasOption(Opt.MULTI)) + if (a.hasOption(Opt.MULTIVALUE)) { for (String s : al) { @@ -343,7 +384,7 @@ public class BootstrapArgs } else if (this.contains(Arg.HEADLESS)) { - // --headless, --noheadless specified => use value + // --headless has been specified on the command line => headless isHeadless = this.getBoolean(Arg.HEADLESS); } else if (this.argsHaveOption(Opt.OUTPUTFILE)) @@ -354,4 +395,9 @@ public class BootstrapArgs } return isHeadless; } + + public boolean outputToStdout() + { + return this.outputToStdout; + } }