JAL-4262 Dialog for GUI and WARN for CLI of old style arguments, or mixed arguments...
[jalview.git] / src / jalview / bin / Commands.java
index 8164182..d910819 100644 (file)
@@ -14,6 +14,7 @@ import java.util.Map;
 
 import jalview.analysis.AlignmentUtils;
 import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.bin.Jalview.ExitCode;
 import jalview.bin.argparser.Arg;
 import jalview.bin.argparser.ArgParser;
 import jalview.bin.argparser.ArgParser.Position;
@@ -140,7 +141,9 @@ public class Commands
     }
     if (argParser.getBoolean(Arg.QUIT))
     {
-      Jalview.getInstance().quit();
+      Jalview.getInstance().exit(
+              "Exiting due to " + Arg.QUIT.argString() + " argument.",
+              ExitCode.OK);
       return true;
     }
     // carry on with jalview.bin.Jalview
@@ -249,21 +252,24 @@ public class Commands
           Console.debug(
                   "Opening '" + openFile + "' in new alignment frame");
           FileLoader fileLoader = new FileLoader(!headless);
-          boolean xception=false;
-          try {
+          boolean xception = false;
+          try
+          {
             af = fileLoader.LoadFileWaitTillLoaded(openFile, protocol,
                     format);
           } catch (Throwable thr)
           {
-            xception=true;
-            Console.error("Couldn't open '"+openFile+"' as "+format+" "+thr.getLocalizedMessage()+ " (Enable debug for full stack trace)");
-            Console.debug("Exception when opening '"+openFile+"'",thr);
-          }
-          finally
+            xception = true;
+            Console.error("Couldn't open '" + openFile + "' as " + format
+                    + " " + thr.getLocalizedMessage()
+                    + " (Enable debug for full stack trace)");
+            Console.debug("Exception when opening '" + openFile + "'", thr);
+          } finally
           {
-            if (af==null && !xception)
+            if (af == null && !xception)
             {
-              Console.info("Ignoring '"+openFile+"' - no alignment data found.");
+              Console.info("Ignoring '" + openFile
+                      + "' - no alignment data found.");
               continue;
             }
           }
@@ -410,7 +416,8 @@ public class Commands
       {
         if (headless)
         {
-          Jalview.exit("Could not open any files in headless mode", 1);
+          Jalview.exit("Could not open any files in headless mode",
+                  ExitCode.NO_FILES);
         }
         else
         {
@@ -946,7 +953,7 @@ public class Commands
 
             Jalview.exit("No valid format specified for "
                     + Arg.OUTPUT.argString() + ". Valid formats are "
-                    + validSB.toString() + ".", 1);
+                    + validSB.toString() + ".", ExitCode.INVALID_FORMAT);
             // this return really shouldn't happen
             return false;
           }