Merge branch 'feature/JAL-629_--output_-_means_output_to_STDOUT' into improvement...
[jalview.git] / src / jalview / bin / argparser / BootstrapArgs.java
index f51e4c5..ec62bcd 100644 (file)
@@ -28,6 +28,8 @@ public class BootstrapArgs
 
   private Set<Type> argsTypes = new HashSet<>();
 
+  private boolean outputToStdout = false;
+
   public static BootstrapArgs getBootstrapArgs(String[] args)
   {
     List<String> argList = new ArrayList<>(Arrays.asList(args));
@@ -53,7 +55,7 @@ public class BootstrapArgs
     {
       if (argFiles.contains(inArgFile))
       {
-        System.err.println(
+        jalview.bin.Console.errPrintln(
                 "Looped argfiles detected: '" + inArgFile.getPath() + "'");
         return;
       }
@@ -127,11 +129,6 @@ public class BootstrapArgs
           }
         }
 
-        if (ArgParser.argMap.containsKey(argName) && val == null)
-        {
-          val = "true";
-        }
-
         Arg a = ArgParser.argMap.get(argName);
 
         if (a != null)
@@ -152,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;
         }
 
@@ -188,6 +205,11 @@ public class BootstrapArgs
         }
         else
         {
+          if (val == null)
+          {
+            val = "true";
+          }
+
           add(a, type, val);
         }
       }
@@ -373,4 +395,9 @@ public class BootstrapArgs
     }
     return isHeadless;
   }
+
+  public boolean outputToStdout()
+  {
+    return this.outputToStdout;
+  }
 }