geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r612934 - in /geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp: CommandLineProcessor.java handler/BooleanHandler.java handler/Handler.java
Date Thu, 17 Jan 2008 19:19:22 GMT
Author: jdillon
Date: Thu Jan 17 11:19:20 2008
New Revision: 612934

URL: http://svn.apache.org/viewvc?rev=612934&view=rev
Log:
(GSHELL-70) Support for negated boolean options

Modified:
    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/handler/BooleanHandler.java
    geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handler.java

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=612934&r1=612933&r2=612934&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
Thu Jan 17 11:19:20 2008
@@ -244,6 +244,10 @@
                         throw new ProcessingException(Messages.UNDEFINED_OPTION.format(arg));
                     }
                 }
+                else if (isKeyValuePair){
+                	// known option, but further processing is required in the handler.
+                	handler.isKeyValuePair = isKeyValuePair;
+                }
                 else {
                     // known option; skip its name
                     params.skip(1);
@@ -330,9 +334,17 @@
         Map<String, Handler> map = new TreeMap<String, Handler>();
 
         for (Handler handler : handlers) {
-            if (handlers.toString().startsWith(keyFilter)) {
-                map.put(handlers.toString(), handler);
-            }
+        	if (keyFilter.contains("--")) {
+        		for (String alias : ((OptionDescriptor)handler.descriptor).aliases()) {
+        			if (alias.startsWith(keyFilter)) {
+        				map.put(alias, handler);
+        			}
+        		}
+        	} else {
+        		if (((OptionDescriptor)handler.descriptor).name().startsWith(keyFilter)) {
+                    map.put(((OptionDescriptor)handler.descriptor).name(), handler);
+                }
+        	}
         }
 
         return map;

Modified: geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/BooleanHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/BooleanHandler.java?rev=612934&r1=612933&r2=612934&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/BooleanHandler.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/BooleanHandler.java
Thu Jan 17 11:19:20 2008
@@ -47,7 +47,15 @@
             setter.set(value);
 
             return 1;
-    	}
+    	} 
+        else if (descriptor instanceof OptionDescriptor && isKeyValuePair) {
+        	String token = params.get(0);
+        	token = token.substring(token.indexOf('=') + 1, token.length());
+        	boolean value = Boolean.parseBoolean(token);
+        	setter.set(value);
+        	
+        	return 1;
+        }
         else {
             if (((OptionDescriptor)descriptor).isArgumentRequired()) {
                 String token = params.get(0);

Modified: geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handler.java?rev=612934&r1=612933&r2=612934&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handler.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handler.java
Thu Jan 17 11:19:20 2008
@@ -31,6 +31,8 @@
 public abstract class Handler<T>
 {
     public final Descriptor descriptor;
+    
+    public Boolean isKeyValuePair = false;
 
     public final Setter<? super T> setter;
 



Mime
View raw message