--- src/java/org/apache/fop/cli/CommandLineOptions.java (revision 702651) +++ src/java/org/apache/fop/cli/CommandLineOptions.java (working copy) @@ -234,6 +234,11 @@ public class CommandLineOptions { * @exception FOPException if there was an error in the format of the options */ private boolean parseOptions(String[] args) throws FOPException { + // do not throw an exception for no args + if (args.length == 0) { + printUsage(); + System.exit(1); + } for (int i = 0; i < args.length; i++) { if (args[i].equals("-x") || args[i].equals("--dump-config")) { @@ -305,6 +310,7 @@ public class CommandLineOptions { i = i + parseAreaTreeOption(args, i); } else if (args[i].equals("-v")) { System.out.println("FOP Version " + Version.getVersion()); + System.exit(1); } else if (args[i].equals("-param")) { if (i + 2 < args.length) { String name = args[++i]; @@ -331,6 +337,7 @@ public class CommandLineOptions { i = i + parseUnknownOption(args, i); } else { printUsage(); + System.exit(1); return false; } } @@ -1033,8 +1040,9 @@ public class CommandLineOptions { * shows the commandline syntax including a summary of all available options and some examples */ public static void printUsage() { + // Remember that the user executes 'fop', not Fop. System.err.println( - "\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] " + "\nUSAGE\nfop [options] [-fo|-xml] infile [-xsl file] " + "[-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl|-ps|-txt|-at [mime]|-print] \n" + " [OPTIONS] \n" + " -d debug mode \n" @@ -1095,28 +1103,29 @@ public class CommandLineOptions { + " XSL-FO file is saved and no rendering is performed. \n" + " (Only available if you use -xml and -xsl parameters)\n\n" + "\n" - + " [Examples]\n" + " Fop foo.fo foo.pdf \n" - + " Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n" - + " Fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf\n" - + " Fop -xml foo.xml -xsl foo.xsl -foout foo.fo\n" - + " Fop -xml - -xsl foo.xsl -pdf -\n" - + " Fop foo.fo -mif foo.mif\n" - + " Fop foo.fo -rtf foo.rtf\n" - + " Fop foo.fo -print\n" - + " Fop foo.fo -awt\n"); + + " [Examples]\n" + " fop foo.fo foo.pdf \n" + + " fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n" + + " fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf\n" + + " fop -xml foo.xml -xsl foo.xsl -foout foo.fo\n" + + " fop -xml - -xsl foo.xsl -pdf -\n" + + " fop foo.fo -mif foo.mif\n" + + " fop foo.fo -rtf foo.rtf\n" + + " fop foo.fo -print\n" + + " fop foo.fo -awt\n"); } /** * shows the options for print output */ private void printUsagePrintOutput() { + // Remember that the user sees /fop', not Fop. System.err.println("USAGE: -print [from[-to][,even|odd]] [-copies numCopies]\n\n" + "Example:\n" - + "all pages: Fop infile.fo -print\n" - + "all pages with two copies: Fop infile.fo -print -copies 2\n" - + "all pages starting with page 7: Fop infile.fo -print 7\n" - + "pages 2 to 3: Fop infile.fo -print 2-3\n" - + "only even page between 10 and 20: Fop infile.fo -print 10-20,even\n"); + + "all pages: fop infile.fo -print\n" + + "all pages with two copies: fop infile.fo -print -copies 2\n" + + "all pages starting with page 7: fop infile.fo -print 7\n" + + "pages 2 to 3: fop infile.fo -print 2-3\n" + + "only even page between 10 and 20: fop infile.fo -print 10-20,even\n"); } /** --- src/java/org/apache/fop/cli/Main.java (revision 702651) +++ src/java/org/apache/fop/cli/Main.java (working copy) @@ -142,6 +142,15 @@ public class Main { * Executes FOP with the given ClassLoader setup. * @param args command-line arguments */ + + // When Fop is started without arguments, it should return its version + // number as well as a short usage statement. + + // When Fop is started with a '-v' argument, it should return its version + // number alone. + + // When Fop is started with an '-h' argument, it should return its short + // help message. public static void startFOP(String[] args) { //System.out.println("static CCL: " // + Thread.currentThread().getContextClassLoader().toString()); @@ -184,6 +193,7 @@ public class Main { } } catch (Exception e) { if (options != null) { + System.out.println("debug: "); options.getLogger().error("Exception", e); if (options.getOutputFile() != null) { options.getOutputFile().delete();