JAL-629 don’t carry on Jalview.main if we’ve already processed command line args...
[jalview.git] / src / jalview / bin / Commands.java
index c05194d..61ee1be 100644 (file)
@@ -48,11 +48,11 @@ public class Commands
 
   private Map<String, AlignFrame> afMap;
 
-  public static void processArgs(ArgParser ap, boolean h)
+  public static boolean processArgs(ArgParser ap, boolean h)
   {
     argParser = ap;
     headless = h;
-
+    boolean argsWereParsed = false;
     if (headless)
     {
       System.setProperty("java.awt.headless", "true");
@@ -73,14 +73,24 @@ public class Commands
           cmds.processLinked(id);
         }
         cmds.processImages(id);
+        argsWereParsed |= cmds.wereParsed();
       }
 
     }
     if (argParser.getBool(Arg.QUIT))
     {
       Jalview.getInstance().quit();
-      // Desktop.instance.quit();
+      return true;
     }
+    // carry on with jalview.bin.Jalview
+    return argsWereParsed;
+  }
+
+  boolean argsWereParsed = false;
+
+  private boolean wereParsed()
+  {
+    return argsWereParsed;
   }
 
   public Commands()
@@ -121,11 +131,12 @@ public class Commands
 
       boolean first = true;
       AlignFrame af;
-      OPEN: for (String openFile : ArgParser.getValues(m, Arg.OPEN))
+      for (String openFile : ArgParser.getValues(m, Arg.OPEN))
       {
         if (openFile == null)
-          continue OPEN;
+          continue;
 
+        argsWereParsed = true;
         if (first)
         {
           first = false;
@@ -150,7 +161,6 @@ public class Commands
             if (!(new File(openFile)).exists())
             {
               Console.warn("Can't find file '" + openFile + "'");
-              continue OPEN;
             }
           }
         }
@@ -328,12 +338,15 @@ public class Commands
           Console.error("Could not open any files in headless mode");
           System.exit(1);
         }
-      }
-      else
-      {
-        Console.warn("No more files to open");
-        if (desktop != null)
-          desktop.setProgressBar(null, progress);
+        // TOREMOVE COMMENT
+        // @Ben assumed this was the GUI version of above, rather then the
+        // first==false state
+        else
+        {
+          Console.warn("No more files to open");
+          if (desktop != null)
+            desktop.setProgressBar(null, progress);
+        }
       }
 
     }
@@ -391,7 +404,7 @@ public class Commands
       AlignFrame af = afMap.get(id);
       if (ArgParser.getArgValues(m, Arg.STRUCTURE) != null)
       {
-        STRUCTURE: for (String val : ArgParser.getValues(m, Arg.STRUCTURE))
+        for (String val : ArgParser.getValues(m, Arg.STRUCTURE))
         {
           SubVal subId = new SubVal(val);
           SequenceI seq = getSpecifiedSequence(af, subId);
@@ -421,14 +434,14 @@ public class Commands
           if (structureFile == null)
           {
             Console.warn("Not provided structure file with '" + val + "'");
-            continue STRUCTURE;
+            continue;
           }
 
           if (!structureFile.exists())
           {
             Console.warn("Structure file '"
                     + structureFile.getAbsoluteFile() + "' not found.");
-            continue STRUCTURE;
+            continue;
           }
 
           Console.debug("Using structure file "
@@ -476,6 +489,10 @@ public class Commands
             }
           }
         }
+        // for moment we disable JSON export
+        Cache.setPropsAreReadOnly(true);
+        Cache.setProperty("EXPORT_EMBBED_BIOJSON", "false");
+
         switch (type)
         {
         case "svg":