|
From: Mike H. <he...@us...> - 2002-07-08 22:40:11
|
Update of /cvsroot/javadocbook/javadocbook/src/net/sf/javadocbook
In directory usw-pr-cvs1:/tmp/cvs-serv20953
Modified Files:
Main.java
Log Message:
Applied Main.java.diff patch from patch 578288.
Index: Main.java
===================================================================
RCS file: /cvsroot/javadocbook/javadocbook/src/net/sf/javadocbook/Main.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Main.java 22 Jun 2002 19:00:11 -0000 1.13
--- Main.java 8 Jul 2002 22:40:08 -0000 1.14
***************
*** 52,55 ****
--- 52,58 ----
import org.xml.sax.SAXException;
import org.apache.commons.cli.Options;
+ import org.apache.commons.cli.CommandLine;
+ import org.apache.commons.cli.ParseException;
+ import org.apache.commons.cli.HelpFormatter;
/**
***************
*** 67,71 ****
public static String PARAM_XHTML = "XHTML";
! public static void transform(InputStream in, OutputStream out, URL styleSheetURL) {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setValidating(false);
--- 70,74 ----
public static String PARAM_XHTML = "XHTML";
! private static void transform(InputStream in, OutputStream out, URL styleSheetURL) {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setValidating(false);
***************
*** 108,131 ****
}
! public static void showUsage() {
! System.out.println("Usage: java -jar javadocbook.jar [options] xml_data");
! System.out.println();
! System.out.println("where options include:");
! System.out.println("-t type\t\tSpecifies the type of transform to be done. Possible");
! System.out.println("\t\tare:");
! System.out.println("\t\t" + PARAM_FO +" - Transforms Docbook XML to FO XML (for PDF converstion)");
! System.out.println("\t\t" + PARAM_HTML + " - Transforms Docbook XML to HTML");
! System.out.println("\t\t" + PARAM_XHTML + " - Transforms Docbook XML to XHTML");
! System.out.println();
! System.out.println("-o filename\tSpecifies the output file to send the output to. If");
! System.out.println("\t\tno file is specified, the standard output is used.");
System.out.println();
! System.out.println("-f\t\tForce recreation of output file. If the output file exists");
! System.out.println("\t\tand is newer than the source XML file, nothing happens unless");
! System.out.println("\t\tthis option is used.");
System.out.println();
System.out.println("For more information go to: http://sourceforge.net/projects/javadocbook/");
System.out.println("To log a bug, go to: http://sourceforge.net/tracker/?func=add&group_id=47837&atid=451047");
System.out.println("To request a feature, go to: http://sourceforge.net/tracker/?func=add&group_id=47837&atid=451050");
}
--- 111,139 ----
}
! private static void argumentError( String message, int error_code ) {
! System.out.println(message);
! System.out.println("Use option --help for command line help.");
! System.exit(error_code);
! }
!
! private static void showUsage( Options opts ) {
! HelpFormatter help = new HelpFormatter();
! help.printHelp("java -jar javadocbook.jar [options] xml_data",
! "\nwhere options include:", opts, "");
! // This footer was easier to format manually then through HelpFormatter.
System.out.println();
! System.out.println("Known types:");
! System.out.println(PARAM_FO + "\t- Transforms Docbook XML to FO XML (for PDF converstion)");
! System.out.println(PARAM_HTML + "\t- Transforms Docbook XML to HTML");
! System.out.println(PARAM_XHTML + "\t- Transforms Docbook XML to XHTML");
System.out.println();
+ System.out.println("For more information visit the project homepage at:");
+ // This really should be http://javadocbook.sourceforge.net/ when the site gets updated.
+ System.out.println("http://sourceforge.net/projects/javadocbook/");
+ /* Old links
System.out.println("For more information go to: http://sourceforge.net/projects/javadocbook/");
System.out.println("To log a bug, go to: http://sourceforge.net/tracker/?func=add&group_id=47837&atid=451047");
System.out.println("To request a feature, go to: http://sourceforge.net/tracker/?func=add&group_id=47837&atid=451050");
+ */
}
***************
*** 136,189 ****
String styleSheet = HTML_STYLE_SHEET;
! /* try {
! // Parse through command line options.
! for(int i = 0; i < args.length; i++) {
! if (args[i].charAt(0) == '-') {
! if (args[i].equals("-o")) {
! i++;
! output = args[i];
! } else if (args[i].equals("-f")) {
! force = true;
! } else if (args[i].equals("-t")) {
! // Parse through types
! String type = args[++i];
! if (type.equals(PARAM_FO)) {
! styleSheet = FO_STYLE_SHEET;
! } else if (type.equals(PARAM_HTML)) {
! styleSheet = HTML_STYLE_SHEET;
! } else if (type.equals(PARAM_XHTML)) {
! styleSheet = XHTML_STYLE_SHEET;
! } else {
! // If specified type is not found, break out.
! throw new Exception();
! }
! } else {
! // If specified option is not found, break out.
! throw new Exception();
! }
} else {
! if (xmlData == null) {
! xmlData = args[i];
! } else {
! throw new Exception();
! }
}
}
! if (xmlData == null) {
! throw new Exception();
}
! } catch (Exception e) {
! showUsage();
! return;
}
- */
-
- Options options = new Options();
- options.addOption('t', "type", true, "Possible types, list them.");
- options.addOption('o', "output", true, "File to write output to.");
- options.addOption('f', "force", false, "Force recreation of output file. If the output file exists and is"
- + "newer than the source XML file, nothing happens unless this option is"
- + "used.");
- options.addOption(
InputStream in;
--- 144,190 ----
String styleSheet = HTML_STYLE_SHEET;
! Options options = new Options();
! options.addOption('t', "type", true, "Specifies the type of transform to be done.");
! options.addOption('o', "output", true, "Specifies the output file to send the output to. "
! + "If no file is specified standard output is used.");
! options.addOption('f', "force", false, "Force recreation of output file. If the output file exists and is "
! + "newer than the source XML file. Default is not to overwrite file.");
! options.addOption('h', "help", false, "Displays this help message.");
! // Option defaults are set above.
! try {
! CommandLine cmd = options.parse(args, true);
! // See what options we have
! if (cmd.hasOption('h')) {
! showUsage(options);
! System.exit(127);
! }
! if (cmd.hasOption('t')) {
! String type = cmd.getOptionValue('t');
! if (type.equalsIgnoreCase(PARAM_FO)) {
! styleSheet = FO_STYLE_SHEET;
! } else if (type.equalsIgnoreCase(PARAM_HTML)) {
! styleSheet = HTML_STYLE_SHEET;
! } else if (type.equalsIgnoreCase(PARAM_XHTML)) {
! styleSheet = XHTML_STYLE_SHEET;
} else {
! // User might need help here.
! argumentError("Unknown type '" + type + "'.", 2);
}
+ type = null;
}
! if (cmd.hasOption('o')) {
! output = cmd.getOptionValue('o');
}
! if (cmd.hasOption('f')) {
! force = true;
! }
! if (cmd.getArgs().length == 1) {
! xmlData = cmd.getArgs()[0];
! } else {
! argumentError("Incorrect number of arguments.", 2);
! }
! } catch (ParseException e) {
! argumentError(e.getMessage(), 2);
}
InputStream in;
***************
*** 222,225 ****
--- 223,229 ----
/*
* $Log$
+ * Revision 1.14 2002/07/08 22:40:08 heathm
+ * Applied Main.java.diff patch from patch 578288.
+ *
* Revision 1.13 2002/06/22 19:00:11 heathm
* In the middle of converting over to use Jakarta Commons CLI.
***************
*** 261,263 ****
* Added GPL notice and a CVS log tag at the bottom of the file.
*
! */
\ No newline at end of file
--- 265,267 ----
* Added GPL notice and a CVS log tag at the bottom of the file.
*
! */
|