JAL-4059 fix that boolean for non-value query string args
[jalview.git] / src / jalview / bin / argparser / BootstrapArgs.java
index a29f7b8..5c21d03 100644 (file)
@@ -55,7 +55,7 @@ public class BootstrapArgs
     {
       if (argFiles.contains(inArgFile))
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Looped argfiles detected: '" + inArgFile.getPath() + "'");
         return;
       }
@@ -152,18 +152,21 @@ public class BootstrapArgs
           // not a bootstrap arg
 
           // make a check for an output going to stdout
-          if (a != null && a.hasOption(Opt.OUTPUTFILE))
+          if (a != null && a.hasOption(Opt.OUTPUTFILE)
+                  && a.hasOption(Opt.STDOUT))
           {
-            System.err.println("###### Found an output");
-            System.err.println("######   val='" + val + "'");
-            System.err
-                    .println("######   next arg='" + args.get(i + 1) + "'");
-            if ((val == null && i + 1 < args.size()
-                    && ArgParser.STDOUTFILENAME.equals(args.get(i + 1)))
-                    || ArgParser.STDOUTFILENAME.equals(val))
+            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;
-              System.err.println("###### Expecting output to stdout");
             }
           }
 
@@ -211,6 +214,13 @@ public class BootstrapArgs
         }
       }
     }
+
+    // if in an argfile, remove it from the hashset so it can be re-used in
+    // another argfile
+    if (inArgFile != null)
+    {
+      argFiles.remove(inArgFile);
+    }
   }
 
   public boolean contains(Arg a)
@@ -289,7 +299,7 @@ public class BootstrapArgs
   private void add(Arg a, Type t, String s)
   {
     List<Map.Entry<Type, String>> l = getOrCreateList(a);
-    if (a.hasOption(Opt.MULTI) || l.size() == 0)
+    if (a.hasOption(Opt.MULTIVALUE) || l.size() == 0)
     {
       l.add(entry(t, s));
     }
@@ -298,7 +308,7 @@ public class BootstrapArgs
   private void addAll(Arg a, Type t, List<String> al)
   {
     List<Map.Entry<Type, String>> l = getOrCreateList(a);
-    if (a.hasOption(Opt.MULTI))
+    if (a.hasOption(Opt.MULTIVALUE))
     {
       for (String s : al)
       {
@@ -381,7 +391,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))