For PR libgcj/5303:
authorTom Tromey <tromey@redhat.com>
Thu, 10 Jan 2002 18:01:05 +0000 (18:01 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Thu, 10 Jan 2002 18:01:05 +0000 (18:01 +0000)
* 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.

From-SVN: r48740

libjava/ChangeLog
libjava/gnu/java/rmi/rmic/RMIC.java

index afa68cecb728960453ce223a9c44f5ab8617cd40..d0190e44cac2272a911f7089a13e8f8a5e25394d 100644 (file)
@@ -1,3 +1,14 @@
+2002-01-10  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.
+
 2002-01-09  Tom Tromey  <tromey@redhat.com>
 
        * gnu/gcj/convert/Convert.java (version): Use java.vm.name
index 1ad0ffb65a1016deed89aeb94ae1ac92f4570e21..0c40a0f66221782b535b700f65fb9c3b737feed0 100644 (file)
@@ -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 @@ public static void main(String args[]) {
                        exception.printStackTrace();
                }
                else {
-                       usage();
+                       System.exit(1);
                }
        }
 }
@@ -82,7 +82,7 @@ public static void main(String args[]) {
 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 @@ private void parseOptions() {
                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 @@ private void parseOptions() {
                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 @@ private void parseOptions() {
                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 @@ private static void usage() {
 "      -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