JAL-629 Fasta sequence id reading whitespace fix. Flexioble pae json keys and structu...
[jalview.git] / src / jalview / bin / Jalview.java
index 6238c7d..e259cc2 100755 (executable)
@@ -301,10 +301,19 @@ public class Jalview
 
     // old ArgsParser
     ArgsParser aparser = new ArgsParser(args);
-    // new ArgParser
-    ArgParser argparser = new ArgParser(args);
     boolean headless = false;
 
+    try
+    {
+      Console.initLogger();
+    } catch (NoClassDefFoundError error)
+    {
+      error.printStackTrace();
+      System.out.println("\nEssential logging libraries not found."
+              + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
+      System.exit(0);
+    }
+
     String usrPropsFile = aparser.getValue("props");
     Cache.loadProperties(usrPropsFile); // must do this before
     if (usrPropsFile != null)
@@ -313,6 +322,31 @@ public class Jalview
               "CMD [-props " + usrPropsFile + "] executed successfully!");
     }
 
+    // set log level from cache properties
+    Console.setLogLevel(Cache.getDefault(Cache.JALVIEWLOGLEVEL, "INFO"));
+
+    // new ArgParser
+    ArgParser argparser = new ArgParser(args); // do this after
+                                               // Console.initLogger, but TODO
+                                               // want --props before then
+                                               // CATCH22
+
+    if (argparser.isSet(Arg.HEADLESS))
+      headless = argparser.getBool(Arg.HEADLESS);
+    boolean commandsSuccess = Commands.processArgs(argparser, headless);
+    if (commandsSuccess)
+    {
+      Console.info("Successfully completed commands");
+      if (headless)
+        System.exit(0);
+    }
+    else
+    {
+      Console.warn("Error when running commands");
+      if (headless)
+        System.exit(1);
+    }
+
     if (!Platform.isJS())
     /**
      * Java only
@@ -386,17 +420,6 @@ public class Jalview
     System.setProperty("http.agent",
             "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
 
-    try
-    {
-      Console.initLogger();
-    } catch (NoClassDefFoundError error)
-    {
-      error.printStackTrace();
-      System.out.println("\nEssential logging libraries not found."
-              + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
-      System.exit(0);
-    }
-
     desktop = null;
 
     setLookAndFeel();
@@ -563,13 +586,6 @@ public class Jalview
       }.start();
     }
 
-    if (argparser.isSet(Arg.HEADLESS))
-      headless = argparser.getBool(Arg.HEADLESS);
-    if (Commands.processArgs(argparser, headless))
-    {
-      System.exit(1);
-    }
-
     String file = null, data = null;
     FileFormatI format = null;
     DataSourceType protocol = null;