JAL-629 Default to FASTA if no format given for output to STDOUT
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 9 Aug 2023 16:21:34 +0000 (17:21 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Wed, 9 Aug 2023 16:21:34 +0000 (17:21 +0100)
src/jalview/bin/Commands.java

index a3d87f7..c08bcc5 100644 (file)
@@ -913,23 +913,30 @@ public class Commands
         }
         if (ff == null)
         {
-          StringBuilder validSB = new StringBuilder();
-          for (String f : validFormats)
-          {
-            if (validSB.length() > 0)
-              validSB.append(", ");
-            validSB.append(f);
-            FileFormatI tff = ffs.forName(f);
-            validSB.append(" (");
-            validSB.append(tff.getExtensions());
-            validSB.append(")");
+          if (stdout)
+          {
+            ff = FileFormat.Fasta;
           }
+          else
+          {
+            StringBuilder validSB = new StringBuilder();
+            for (String f : validFormats)
+            {
+              if (validSB.length() > 0)
+                validSB.append(", ");
+              validSB.append(f);
+              FileFormatI tff = ffs.forName(f);
+              validSB.append(" (");
+              validSB.append(tff.getExtensions());
+              validSB.append(")");
+            }
 
-          Jalview.exit("No valid format specified for "
-                  + Arg.OUTPUT.argString() + ". Valid formats are "
-                  + validSB.toString() + ".", 1);
-          // this return really shouldn't happen
-          return false;
+            Jalview.exit("No valid format specified for "
+                    + Arg.OUTPUT.argString() + ". Valid formats are "
+                    + validSB.toString() + ".", 1);
+            // this return really shouldn't happen
+            return false;
+          }
         }
 
         String savedBackupsPreference = Cache