JAL-3662 simple fix for CLI not using right format for output of
authorBobHanson <hansonr@stolaf.edu>
Tue, 16 Jun 2020 23:00:51 +0000 (18:00 -0500)
committerBobHanson <hansonr@stolaf.edu>
Tue, 16 Jun 2020 23:00:51 +0000 (18:00 -0500)
alignment.

src/jalview/bin/Jalview.java

index 4a5c733..4522167 100755 (executable)
@@ -110,6 +110,7 @@ public class Jalview implements ApplicationSingletonI
   // }
   public static Jalview getInstance()
   {
+    System.out.println("Hello, MW!!!!!!!!!!!!");
     return (Jalview) ApplicationSingletonProvider
             .getInstance(Jalview.class);
   }
@@ -330,9 +331,14 @@ public class Jalview implements ApplicationSingletonI
       if (aparser.contains("nodisplay") || aparser.contains("nogui")
               || aparser.contains("headless"))
       {
+        // BH Is this necessary? Seems like a hack; was removed for applet branch 
         System.setProperty("java.awt.headless", "true");
         headless = true;
       }
+      if ("true".equals(System.getProperty("java.awt.headless")))
+      {
+        headless = true;
+      }
       // <<?
 
       // anything else!
@@ -372,11 +378,6 @@ public class Jalview implements ApplicationSingletonI
       }
       defs = aparser.getValue("setprop");
     }
-    if (System.getProperty("java.awt.headless") != null
-            && System.getProperty("java.awt.headless").equals("true"))
-    {
-      headless = true;
-    }
     System.setProperty("http.agent",
             "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
     try
@@ -1031,24 +1032,24 @@ public class Jalview implements ApplicationSingletonI
         System.out.println(
                 "Creating image map: " + imageFile.getAbsolutePath());
         continue;
-      }
-      if (!Platform.isJS()) /** @j2sIgnore */
-      {
-        // skipping outputFormat?
-        System.out.println("Unknown arg: " + outputFormat);      
-        fname = new File(aparser.nextValue()).getAbsolutePath();
-        af.saveAlignment(fname, format);
-        if (af.isSaveAlignmentSuccessful())
+      default:
+        format = FileFormats.getInstance().forName(outputFormat);
+        if (format == null)
         {
-          System.out.println(
-                  "Written alignment in " + format + " format to " + fname);
+          System.out.println("Invalid file format: " + outputFormat);
+          break;
         }
-        else
+        fname = new File(aparser.nextValue()).getAbsolutePath();
+        af.saveAlignment(fname, format);
+        if (!af.isSaveAlignmentSuccessful())
         {
           System.out.println("Error writing file " + fname + " in " + format
                   + " format!!");
+          break;
         }
+        continue;
       }
+      System.out.println("Unknown arg: " + outputFormat);      
       break;
     }
     while (aparser.getSize() > 0)