Patch: FYI: rmic -vs- PR 5303
Tom Tromey
tromey@redhat.com
Thu Jan 10 09:59:00 GMT 2002
I'm checking this in.
This adds --help and --version options to rmic. This is part of PR 5303.
I've also checked this in to Classpath.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
For PR libgcj/5303:
* gnu/java/rmi/rmic/RMIC.java (parseOptions): Handle --help and
--version. Recognize GNU-style long options. Print GNU-style
error messages.
(usage): Print GNU-style help. Exit with status 0.
(error): New method.
(run): Print error message if no class names found.
(main): Don't print usage on error.
Index: gnu/java/rmi/rmic/RMIC.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/rmi/rmic/RMIC.java,v
retrieving revision 1.3
diff -u -r1.3 RMIC.java
--- gnu/java/rmi/rmic/RMIC.java 2001/10/31 00:48:16 1.3
+++ gnu/java/rmi/rmic/RMIC.java 2002/01/10 17:57:14
@@ -1,5 +1,5 @@
/*
- Copyright (c) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
+ Copyright (c) 1996, 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -74,7 +74,7 @@
exception.printStackTrace();
}
else {
- usage();
+ System.exit(1);
}
}
}
@@ -82,7 +82,7 @@
public boolean run() {
parseOptions();
if (next >= args.length) {
- return (false);
+ error("no class names found");
}
for (int i = next; i < args.length; i++) {
try {
@@ -887,6 +887,11 @@
String arg = args[next];
next++;
+ // Accept `--' options if they look long enough.
+ if (arg.length() > 3 && arg.charAt(0) == '-'
+ && arg.charAt(1) == '-')
+ arg = arg.substring(1);
+
if (arg.equals("-keep")) {
keep = true;
}
@@ -920,6 +925,20 @@
else if (arg.equals("-classpath")) {
next++;
}
+ else if (arg.equals("-help")) {
+ usage();
+ }
+ else if (arg.equals("-version")) {
+ System.out.println("rmic (GNU "
+ + System.getProperty("java.vm.name")
+ + ") "
+ + System.getProperty("java.vm.version"));
+ System.out.println();
+ System.out.println("Copyright 1996, 1997, 1998, 1999, 2001, 2002 Free Software Foundation");
+ System.out.println("This is free software; see the source for copying conditions. There is NO");
+ System.out.println("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.");
+ System.exit(0);
+ }
else if (arg.equals("-d")) {
destination = args[next];
next++;
@@ -927,15 +946,21 @@
else if (arg.charAt(1) == 'J') {
}
else {
- System.err.println("Unknown option: " + arg);
+ error("unrecognized option `" + arg + "'");
}
}
}
+private static void error(String message) {
+ System.err.println("rmic: " + message);
+ System.err.println("Try `rmic --help' for more information.");
+ System.exit(1);
+}
+
private static void usage() {
System.out.println(
-"usage: rmic [-options] classes\n" +
-"Options are:\n" +
+"Usage: rmic [OPTION]... CLASS...\n" +
+"\n" +
" -keep Don't delete any intermediate files\n" +
" -keepgenerated Same as -keep\n" +
" -v1.1 Java 1.1 style stubs only\n" +
@@ -949,8 +974,13 @@
" -classpath <path> * Use given path as classpath\n" +
" -d <directory> Specify where to place generated classes\n" +
" -J<flag> * Pass flag to Java\n" +
-" * Option currently ignored"
+" -help Print this help, then exit\n" +
+" -version Print version number, then exit\n" +
+"\n" +
+" * Option currently ignored\n" +
+"Long options can be used with `--option' form as well."
);
+ System.exit(0);
}
static class MethodRef
More information about the Java-patches
mailing list