JAL-629 Move more stdout messages to stderr when outputting file to stdout
[jalview.git] / src / jalview / bin / argparser / BootstrapArgs.java
index 4b7b180..a29f7b8 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));
@@ -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,24 @@ 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))
+          {
+            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))
+            {
+              this.outputToStdout = true;
+              System.err.println("###### Expecting output to stdout");
+            }
+          }
+
           continue;
         }
 
@@ -188,6 +202,11 @@ public class BootstrapArgs
         }
         else
         {
+          if (val == null)
+          {
+            val = "true";
+          }
+
           add(a, type, val);
         }
       }
@@ -373,4 +392,9 @@ public class BootstrapArgs
     }
     return isHeadless;
   }
+
+  public boolean outputToStdout()
+  {
+    return this.outputToStdout;
+  }
 }