]> source.dussan.org Git - aspectj.git/commitdiff
- special-casing -help to avoid printing usage twice
authorwisberg <wisberg>
Tue, 6 May 2003 05:17:50 +0000 (05:17 +0000)
committerwisberg <wisberg>
Tue, 6 May 2003 05:17:50 +0000 (05:17 +0000)
- guarding usage against loading eclipse message,
  which it did if called before some instance loaded the
  bundle (which should probably be loaded in a
  static initializer)

org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java

index 128a4a917b3bf3fdb59efef0c712f74f40843244..64dab72442778e42eba55f67cbdfa5a12d2cf048 100644 (file)
@@ -50,6 +50,13 @@ public class AjdtCommand implements ICommand {
                buildManager = new AjBuildManager(handler); 
                savedArgs = new String[args.length];
         System.arraycopy(args, 0, savedArgs, 0, savedArgs.length);
+        for (int i = 0; i < args.length; i++) {
+            if ("-help".equals(args[i])) {
+                // should be info, but handler usually suppresses
+                MessageUtil.abort(handler, BuildArgParser.getUsage());
+                return true;
+            }
+        }
         return doCommand(handler, false);
     }
 
index 6955b4744a431e13bda8dfbb6f8bca2f8ad85aa1..b64b095f69dd7163eef99c3eae75c5d9fd9a2003 100644 (file)
@@ -42,6 +42,7 @@ import org.eclipse.jdt.internal.compiler.batch.Main;
 public class BuildArgParser extends Main {
 
        private static final String BUNDLE_NAME = "org.aspectj.ajdt.ajc.messages";
+    private static boolean LOADED_BUNDLE = false;
     
     /** to initialize super's PrintWriter but refer to underlying StringWriter */
     private static class StringPrintWriter extends PrintWriter {
@@ -54,6 +55,9 @@ public class BuildArgParser extends Main {
 
     /** @return multi-line String usage for the compiler */    
     public static String getUsage() {
+        if (!LOADED_BUNDLE) { // get eclipse usage unless bundle loaded...
+            new BuildArgParser();
+        }
         return Main.bind("misc.usage", Main.bind("compiler.version"));
     }
     
@@ -72,6 +76,9 @@ public class BuildArgParser extends Main {
        public BuildArgParser(PrintWriter writer) {
                super(writer, writer, false);
                bundle = ResourceBundle.getBundle(BUNDLE_NAME);
+        if (!LOADED_BUNDLE) {
+            LOADED_BUNDLE = true;
+        }
         if (writer instanceof StringPrintWriter) {
             errorSink = ((StringPrintWriter) writer).stringWriter.getBuffer();
         } else {