You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2007/11/06 23:08:01 UTC
svn commit: r592571 - in /geronimo/gshell/trunk:
gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/
gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/
Author: jdillon
Date: Tue Nov 6 14:08:00 2007
New Revision: 592571
URL: http://svn.apache.org/viewvc?rev=592571&view=rev
Log:
(GSHELL-36) Applying Jason Warner's patch to fix --help w/required bits
Modified:
geronimo/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/CommandLineProcessor.java
geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/Option.java
Modified: geronimo/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java?rev=592571&r1=592570&r2=592571&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java (original)
+++ geronimo/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java Tue Nov 6 14:08:00 2007
@@ -43,7 +43,7 @@
protected Variables variables;
- @Option(name="-h", aliases={"--help"}, description="Display this help message")
+ @Option(name="-h", aliases={"--help"}, description="Display this help message", requireOverride=true)
private boolean displayHelp;
public String getId() {
Modified: geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/CommandLineProcessor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/CommandLineProcessor.java?rev=592571&r1=592570&r2=592571&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/CommandLineProcessor.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/CommandLineProcessor.java Tue Nov 6 14:08:00 2007
@@ -53,6 +53,8 @@
private boolean stopAtNonOption = false;
+ private boolean overrideRequiredArguments = false;
+
public CommandLineProcessor(final Object bean) throws IllegalAnnotationError {
assert bean != null;
@@ -158,7 +160,9 @@
checkOptionNotInMap(alias);
}
+ overrideRequiredArguments = (option.requireOverride() || overrideRequiredArguments) ? true : false;
optionHandlers.add(handler);
+
}
private void checkOptionNotInMap(final String name) throws IllegalAnnotationError {
@@ -285,17 +289,19 @@
//
// Ensure that all required option handlers are present
- for (Handler handler : optionHandlers) {
- if (handler.descriptor.required() && !present.contains(handler)) {
- throw new ProcessingException(Messages.REQUIRED_OPTION_MISSING.format(handler.descriptor.toString()));
- }
- }
-
- // Ensure that all required argument handlers are present
- for (Handler handler : argumentHandlers) {
- if (handler.descriptor.required() && !present.contains(handler)) {
- throw new ProcessingException(Messages.REQUIRED_ARGUMENT_MISSING.format(handler.descriptor.toString()));
- }
+ if (!overrideRequiredArguments) {
+ for (Handler handler : optionHandlers) {
+ if (handler.descriptor.required() && !present.contains(handler)) {
+ throw new ProcessingException(Messages.REQUIRED_OPTION_MISSING.format(handler.descriptor.toString()));
+ }
+ }
+
+ // Ensure that all required argument handlers are present
+ for (Handler handler : argumentHandlers) {
+ if (handler.descriptor.required() && !present.contains(handler)) {
+ throw new ProcessingException(Messages.REQUIRED_ARGUMENT_MISSING.format(handler.descriptor.toString()));
+ }
+ }
}
}
Modified: geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/Option.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/Option.java?rev=592571&r1=592570&r2=592571&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/Option.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/Option.java Tue Nov 6 14:08:00 2007
@@ -50,4 +50,6 @@
Class<? extends Handler> handler() default Handler.class;
boolean multiValued() default false;
+
+ boolean requireOverride() default false;
}