JAL-4353 Add secondary Types for Args, for STRUCTUREIMAGE Type and restrict structure...
[jalview.git] / src / jalview / bin / argparser / BootstrapArgs.java
index 32eb91a..51f8147 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.bin.argparser;
 
 import java.io.File;
@@ -140,10 +160,12 @@ public class BootstrapArgs
               argsOptions.add(opt);
             }
           }
-          Type t = a.getType();
-          if (!argsTypes.contains(t))
+          for (Type t : a.getTypes())
           {
-            argsTypes.add(t);
+            if (!argsTypes.contains(t))
+            {
+              argsTypes.add(t);
+            }
           }
         }
 
@@ -152,11 +174,19 @@ 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))
           {
-            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;
             }
@@ -206,6 +236,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)
@@ -284,7 +321,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));
     }
@@ -293,7 +330,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)
       {
@@ -376,7 +413,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))