geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r699363 - in /geronimo/gshell/trunk: gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/ gshell-remote/gshell-remote-server/src/main...
Date Fri, 26 Sep 2008 15:20:29 GMT
Author: jdillon
Date: Fri Sep 26 08:20:29 2008
New Revision: 699363

URL: http://svn.apache.org/viewvc?rev=699363&view=rev
Log:
Allow any order of <gshell:command> and <gshell:alias> w/in <gshell:command-bundle>
Add default aliases for gshell-builtins and gshell-remote-server
Support help for aliases

Modified:
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml
    geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java?rev=699363&r1=699362&r2=699363&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java
Fri Sep 26 08:20:29 2008
@@ -30,6 +30,7 @@
 import org.apache.geronimo.gshell.registry.CommandRegistry;
 import org.apache.geronimo.gshell.registry.NoSuchCommandException;
 import org.apache.geronimo.gshell.registry.AliasRegistry;
+import org.apache.geronimo.gshell.registry.NoSuchAliasException;
 import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,6 +51,9 @@
     @Autowired
     private CommandRegistry commandRegistry;
 
+    @Autowired
+    private AliasRegistry aliasRegistry;
+
     @Argument
     private String commandName;
 
@@ -79,21 +83,31 @@
             return Result.SUCCESS;
         }
         catch (NoSuchCommandException e) {
-            //
-            // FIXME: When the commandName is really an alias, show the alias details here
instead of complaining
-            //
-            
-            io.out.print("Command ");
-            io.out.print(Renderer.encode(commandName, Code.BOLD));
-            io.out.println(" not found.");
-
-            io.out.print("Try ");
-            io.out.print(Renderer.encode("help", Code.BOLD));
-            io.out.println(" for a list of available commands.");
+            try {
+                assert aliasRegistry != null;
+                String alias = aliasRegistry.getAlias(commandName);
+                
+                io.out.print("Command ");
+                io.out.print(Renderer.encode(commandName, Code.BOLD));
+                io.out.print(" is an alias to: ");
+                io.out.println(Renderer.encode(alias, Code.BOLD));
+                io.out.println();
 
-            io.out.println();
+                return Result.SUCCESS;
+            }
+            catch (NoSuchAliasException e1) {
+                io.out.print("Command ");
+                io.out.print(Renderer.encode(commandName, Code.BOLD));
+                io.out.println(" not found.");
+
+                io.out.print("Try ");
+                io.out.print(Renderer.encode("help", Code.BOLD));
+                io.out.println(" for a list of available commands.");
 
-            return Result.FAILURE;
+                io.out.println();
+
+                return Result.FAILURE;
+            }
         }
     }
 

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml?rev=699363&r1=699362&r2=699363&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml
Fri Sep 26 08:20:29 2008
@@ -37,10 +37,14 @@
                 <gshell:action class="org.apache.geronimo.gshell.commands.builtins.ExitAction"/>
             </gshell:command>
 
+            <gshell:alias name="quit" alias="exit"/>
+
             <gshell:command name="echo">
                 <gshell:action class="org.apache.geronimo.gshell.commands.builtins.EchoAction"/>
             </gshell:command>
 
+            <gshell:alias name="print" alias="echo"/>
+
             <gshell:command name="clear" type="stateless">
                 <gshell:action class="org.apache.geronimo.gshell.commands.builtins.ClearAction"/>
             </gshell:command>
@@ -49,6 +53,8 @@
                 <gshell:action class="org.apache.geronimo.gshell.commands.builtins.SourceAction"/>
             </gshell:command>
 
+            <gshell:alias name="." alias="source"/>
+
             <gshell:command name="set">
                 <gshell:action class="org.apache.geronimo.gshell.commands.builtins.SetAction"/>
             </gshell:command>

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml?rev=699363&r1=699362&r2=699363&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml
Fri Sep 26 08:20:29 2008
@@ -32,6 +32,8 @@
             <gshell:command name="rsh-server">
                 <gshell:action class="org.apache.geronimo.gshell.remote.server.RshServerCommand"/>
             </gshell:command>
+
+            <gshell:alias name="rshd" alias="rsh-server"/>
         </gshell:command-bundle>
     </gshell:plugin>
 

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd?rev=699363&r1=699362&r2=699363&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd
Fri Sep 26 08:20:29 2008
@@ -59,8 +59,10 @@
             </xsd:annotation>
             <xsd:sequence>
                 <xsd:element ref="beans:description" minOccurs="0" maxOccurs="1"/>
-                <xsd:element ref="command" minOccurs="0" maxOccurs="unbounded"/>
-                <xsd:element ref="alias" minOccurs="0" maxOccurs="unbounded"/>
+                <xsd:choice minOccurs="0" maxOccurs="unbounded">
+					<xsd:element ref="command"/>
+					<xsd:element ref="alias"/>
+				</xsd:choice>
             </xsd:sequence>
             <xsd:attribute name="name" type="xsd:string" use="required"/>
         </xsd:complexType>
@@ -75,6 +77,11 @@
             </xsd:annotation>
             <xsd:sequence>
                 <xsd:element ref="beans:description" minOccurs="0" maxOccurs="1"/>
+                <!--
+                NOTE: Not using an xsd:choice here, as I can't seem to figure out how to
get it to properly
+                      validate the min/max of the containted elements.  W/o the xsd:choice
the validation
+                      works, though have to define elements in order :-(
+                -->
                 <xsd:element ref="action" minOccurs="1" maxOccurs="1"/>
                 <xsd:element ref="documenter" minOccurs="0" maxOccurs="1"/>
                 <xsd:element ref="completer" minOccurs="0" maxOccurs="1"/>

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml?rev=699363&r1=699362&r2=699363&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml
Fri Sep 26 08:20:29 2008
@@ -37,6 +37,8 @@
                 This is a test bundle.
             </description>
 
+            <gshell:alias name="1" alias="2"/>
+
             <gshell:command name="a">
                 <description>
                     This is a test command.
@@ -45,6 +47,8 @@
                 <gshell:action class="org.apache.geronimo.gshell.wisdom.config.DummyAction"/>
             </gshell:command>
 
+            <gshell:alias name="foo" alias="bar"/>
+
             <gshell:command name="b" type="stateless">
                 <gshell:action class="org.apache.geronimo.gshell.wisdom.config.DummyAction"/>
             </gshell:command>
@@ -70,7 +74,21 @@
                 <gshell:message-source class="org.apache.geronimo.gshell.wisdom.command.CommandMessageSource"/>
             </gshell:command>
 
-            <gshell:alias name="foo" alias="bar"/>
+            <gshell:command name="f">
+                <gshell:action class="org.apache.geronimo.gshell.wisdom.config.DummyAction"/>
+                <gshell:completer class="org.apache.geronimo.gshell.wisdom.command.NullCommandCompleter"/>
+            </gshell:command>
+
+            <!--
+            <gshell:command name="g">
+                <gshell:completer class="org.apache.geronimo.gshell.wisdom.command.NullCommandCompleter"/>
+            </gshell:command>
+
+            <gshell:command name="h">
+                <gshell:action class="org.apache.geronimo.gshell.wisdom.config.DummyAction"/>
+                <gshell:action class="org.apache.geronimo.gshell.wisdom.config.DummyAction"/>
+            </gshell:command>
+            -->
 
             <gshell:alias name="bar" alias="foo">
                 <description>



Mime
View raw message