From: wisberg Date: Tue, 6 May 2003 05:17:50 +0000 (+0000) Subject: - special-casing -help to avoid printing usage twice X-Git-Tag: V1_1_0_RC2~60 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f19d5143d4427db03dc662c26811bb91267d465b;p=aspectj.git - special-casing -help to avoid printing usage twice - 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) --- diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java index 128a4a917..64dab7244 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java @@ -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); } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java index 6955b4744..b64b095f6 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java @@ -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 {