JAL-4285 JAL-4262 Added a scrollable dialog to display errors. Moved old-style CLI...
[jalview.git] / src / jalview / bin / Commands.java
index cd72e60..8312b29 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;
@@ -142,26 +143,15 @@ public class Commands
     }
 
     // report errors
-    StringBuilder sb = new StringBuilder();
-    for (String error : errors)
-    {
-      sb.append("- " + error);
-      sb.append("\n");
-    }
-    if (Platform.isHeadless())
-    {
-      Console.debug("All errors from command line argument commands:\n"
-              + sb.toString());
-    }
-    else
-    {
-      // scrollable dialog box
-
-    }
+    Console.debug("All errors from command line argument commands:\n"
+            + errorsToString());
+    // gui errors reported in Jalview
 
     if (argParser.getBoolean(Arg.QUIT))
     {
-      Jalview.exit("Exiting due to " + Arg.QUIT.argString(), 0);
+      Jalview.getInstance().exit(
+              "Exiting due to " + Arg.QUIT.argString() + " argument.",
+              ExitCode.OK);
       return true;
     }
     // carry on with jalview.bin.Jalview
@@ -441,7 +431,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
         {
@@ -1172,4 +1163,20 @@ public class Commands
 
     return whatNext.OKAY;
   }
+
+  public List<String> getErrors()
+  {
+    return errors;
+  }
+
+  public String errorsToString()
+  {
+    StringBuilder sb = new StringBuilder();
+    for (String error : errors)
+    {
+      sb.append("- " + error);
+      sb.append("\n");
+    }
+    return sb.toString();
+  }
 }