geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r698123 - in /geronimo/gshell/trunk: gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/ gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/ gshell-commands/gshell-admin/src/main/resources/META-INF/spr...
Date Tue, 23 Sep 2008 10:30:46 GMT
Author: jdillon
Date: Tue Sep 23 03:30:45 2008
New Revision: 698123

URL: http://svn.apache.org/viewvc?rev=698123&view=rev
Log:
Allow clp token to be resolved from messages for i18n
Fixed formating from metaVar -> token refactor (damn intellij)
Changed install-plugin to pull tokens from messages, updated output/logging
Changed list-plugins to stateless, updated output/logging

Modified:
    geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
    geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/InstallPluginAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/ListPluginsAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml
    geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/org/apache/geronimo/gshell/commands/admin/InstallPluginAction.properties
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/java/org/apache/geronimo/gshell/commands/repository/ResolveAction.java
    geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java
    geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java
    geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/Printer.java

Modified: geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=698123&r1=698122&r2=698123&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
(original)
+++ geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
Tue Sep 23 03:30:45 2008
@@ -113,13 +113,13 @@
         }
     }
 
-    @Option(name="-c", aliases={"--commands"}, token ="STRING")
+    @Option(name="-c", aliases={"--commands"}, token="STRING")
     private String commands;
 
-    @Argument(token ="COMMAND")
+    @Argument(token="COMMAND")
     private List<String> commandArgs = null;
 
-    @Option(name="-D", aliases={"--define"}, token ="NAME=VALUE")
+    @Option(name="-D", aliases={"--define"}, token="NAME=VALUE")
     private void setSystemProperty(final String nameValue) {
         assert nameValue != null;
 
@@ -144,7 +144,7 @@
         ANSI.setEnabled(flag);
     }
 
-    @Option(name="-T", aliases={"--terminal"}, token ="TYPE", argumentRequired=true)
+    @Option(name="-T", aliases={"--terminal"}, token="TYPE", argumentRequired=true)
     private void setTerminalType(String type) {
         type = type.toLowerCase();
 

Modified: geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/InstallPluginAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/InstallPluginAction.java?rev=698123&r1=698122&r2=698123&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/InstallPluginAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/InstallPluginAction.java
Tue Sep 23 03:30:45 2008
@@ -42,13 +42,13 @@
     @Autowired
     private PluginManager pluginManager;
 
-    @Option(name="-g", aliases={"--groupId"}, argumentRequired=true, token ="GROUP-ID", required=true)
+    @Option(name="-g", aliases={"--groupId"}, argumentRequired=true, required=true)
     private String groupId;
 
-    @Option(name="-a", aliases={"--artifactId"}, argumentRequired=true, token ="ARTIFACT-ID",
required=true)
+    @Option(name="-a", aliases={"--artifactId"}, argumentRequired=true, required=true)
     private String artifactId;
 
-    @Option(name="-v", aliases={"--version"}, argumentRequired=true, token ="VERSION", required=true)
+    @Option(name="-v", aliases={"--version"}, argumentRequired=true, required=true)
     private String version;
     
     public Object execute(final CommandContext context) throws Exception {
@@ -60,16 +60,20 @@
         artifact.setArtifactId(artifactId);
         artifact.setVersion(version);
 
-        io.out.println("Loading plugin: " + artifact.getId());
+        io.info("Loading plugin: {}", artifact.getId());
         
         assert pluginManager != null;
+        log.debug("Plugin manager: {}", pluginManager);
+
         try {
             pluginManager.loadPlugin(artifact);
+
             return Result.SUCCESS;
         }
         catch (Exception e) {
             log.error("Failed to load plugin", e);
-            return Result.FAILURE;
         }
+
+        return Result.FAILURE;
     }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/ListPluginsAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/ListPluginsAction.java?rev=698123&r1=698122&r2=698123&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/ListPluginsAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/ListPluginsAction.java
Tue Sep 23 03:30:45 2008
@@ -48,12 +48,14 @@
         IO io = context.getIo();
 
         assert pluginManager != null;
+        log.debug("Plugin manager: {}", pluginManager);
+
         Set<Plugin> plugins = pluginManager.getPlugins();
 
-        io.out.println("Installed plugins:");
+        io.info("Found {} plugins:", plugins.size());
 
         for (Plugin plugin : plugins) {
-            io.out.println("    " + plugin.getId());
+            io.info("    {}", plugin.getId());
         }
         
         return Result.SUCCESS;

Modified: geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml?rev=698123&r1=698122&r2=698123&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml
Tue Sep 23 03:30:45 2008
@@ -50,8 +50,8 @@
 
         <property name="commands">
             <list>
-                <bean parent="statefulCommandTemplate">
-                    <property name="actionId" value="gshell-admin:list-plugins"/>
+                <bean parent="statelessCommandTemplate">
+                    <property name="action" ref="gshell-admin:list-plugins"/>
                 </bean>
 
                 <bean parent="statefulCommandTemplate">

Modified: geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/org/apache/geronimo/gshell/commands/admin/InstallPluginAction.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/org/apache/geronimo/gshell/commands/admin/InstallPluginAction.properties?rev=698123&r1=698122&r2=698123&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/org/apache/geronimo/gshell/commands/admin/InstallPluginAction.properties
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/org/apache/geronimo/gshell/commands/admin/InstallPluginAction.properties
Tue Sep 23 03:30:45 2008
@@ -26,10 +26,13 @@
 command.description=Install a GShell plugin.
 
 command.option.groupId=Specify the groupId
+command.option.groupId.token=GROUP-ID
 
 command.option.artifactId=Specify the artifactId
+command.option.artifactId.token=ARTIFACT-ID
 
 command.option.version=Specify the version
+command.option.version.token=VERSION
 
 command.manual=\
   TODO: install-plugin manual
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitAction.java?rev=698123&r1=698122&r2=698123&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitAction.java
Tue Sep 23 03:30:45 2008
@@ -36,7 +36,7 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    @Argument(token ="CODE")
+    @Argument(token="CODE")
     private int exitCode = 0;
 
     public Object execute(final CommandContext context) throws Exception {

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=698123&r1=698122&r2=698123&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
Tue Sep 23 03:30:45 2008
@@ -49,7 +49,7 @@
     @Autowired
     private CommandRegistry commandRegistry;
 
-    @Argument(token ="COMMAND")
+    @Argument(token="COMMAND")
     private String commandName;
 
     private Renderer renderer = new Renderer();

Modified: geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaAction.java?rev=698123&r1=698122&r2=698123&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaAction.java
Tue Sep 23 03:30:45 2008
@@ -44,13 +44,13 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    @Option(name="-m", aliases={"--method"}, token ="METHOD")
+    @Option(name="-m", aliases={"--method"}, token="METHOD")
     private String methodName = "main";
 
-    @Argument(index=0, token ="CLASSNAME", required=true)
+    @Argument(index=0, token="CLASSNAME", required=true)
     private String className;
 
-    @Argument(index=1, token ="ARG")
+    @Argument(index=1, token="ARG")
     private List<String> args;
 
     public Object execute(final CommandContext context) throws Exception {

Modified: geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/java/org/apache/geronimo/gshell/commands/repository/ResolveAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/java/org/apache/geronimo/gshell/commands/repository/ResolveAction.java?rev=698123&r1=698122&r2=698123&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/java/org/apache/geronimo/gshell/commands/repository/ResolveAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/java/org/apache/geronimo/gshell/commands/repository/ResolveAction.java
Tue Sep 23 03:30:45 2008
@@ -53,23 +53,23 @@
     // TODO: Consider using <g>:<a>:<v>:<s>:<t> notation instead
of, or in addtion this?
     //
     
-    @Option(name="-g", aliases={"--groupId"}, argumentRequired=true, token ="GROUP-ID", required=true)
+    @Option(name="-g", aliases={"--groupId"}, argumentRequired=true, token="GROUP-ID", required=true)
     private String groupId;
 
-    @Option(name="-a", aliases={"--artifactId"}, argumentRequired=true, token ="ARTIFACT-ID",
required=true)
+    @Option(name="-a", aliases={"--artifactId"}, argumentRequired=true, token="ARTIFACT-ID",
required=true)
     private String artifactId;
 
-    @Option(name="-v", aliases={"--version"}, argumentRequired=true, token ="VERSION", required=true)
+    @Option(name="-v", aliases={"--version"}, argumentRequired=true, token="VERSION", required=true)
     private String version;
 
-    @Option(name="-t", aliases={"--type"}, argumentRequired=true, token ="TYPE")
+    @Option(name="-t", aliases={"--type"}, argumentRequired=true, token="TYPE")
     private String type = "jar";
 
     //
     // TODO: Add classifier
     //
 
-    @Option(name="-s", aliases={"--scope"}, argumentRequired=true, token ="SCOPE")
+    @Option(name="-s", aliases={"--scope"}, argumentRequired=true, token="SCOPE")
     private String scope;
 
     @Option(name="-T", aliases={"--transitive"})

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java?rev=698123&r1=698122&r2=698123&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java
Tue Sep 23 03:30:45 2008
@@ -46,19 +46,19 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
     
-    @Option(name="-b", aliases={"--bind"}, token ="URI")
+    @Option(name="-b", aliases={"--bind"}, token="URI")
     private URI local;
 
-    @Option(name="-u", aliases={"--username"}, token ="USERNAME")
+    @Option(name="-u", aliases={"--username"}, token="USERNAME")
     private String username;
 
-    @Option(name="-p", aliases={"--password"}, token ="PASSWORD")
+    @Option(name="-p", aliases={"--password"}, token="PASSWORD")
     private String password;
     
-    @Argument(token ="URI", required=true, index=0)
+    @Argument(token="URI", required=true, index=0)
     private URI remote;
 
-    @Argument(token ="COMMAND", index=1, multiValued=true)
+    @Argument(token="COMMAND", index=1, multiValued=true)
     private List<String> command = new ArrayList<String>();
 
     private BeanContainer container;

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java?rev=698123&r1=698122&r2=698123&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java
Tue Sep 23 03:30:45 2008
@@ -44,7 +44,7 @@
     @Option(name="-b", aliases={ "--background"})
     private boolean background;
 
-    @Argument(token ="URI", required=true)
+    @Argument(token="URI", required=true)
     private URI location;
 
     private BeanContainer container;

Modified: geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/Printer.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/Printer.java?rev=698123&r1=698122&r2=698123&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/Printer.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/Printer.java
Tue Sep 23 03:30:45 2008
@@ -97,13 +97,34 @@
     private String getToken(final Handler handler) {
         assert handler != null;
 
-        String token = handler.descriptor.getToken();
-        if (token == null) {
-            token = handler.getDefaultToken();
+        Descriptor descriptor = handler.descriptor;
+        String token = descriptor.getToken();
+
+        // If we have i18n messages for the command, then try to resolve the token further
+        if (messages != null) {
+            String code = token;
+
+            // If there is no coded, then generate one
+            if (code == null) {
+                if (descriptor instanceof ArgumentDescriptor) {
+                    code = "argument." + descriptor.getId() + ".token";
+                }
+                else {
+                    code = "option." + descriptor.getId() + ".token";
+                }
+            }
+
+            // Resolve the text in the message source
+            try {
+                token = messages.getMessage(code);
+            }
+            catch (ResourceNotFoundException e) {
+                // Just use the code as the message
+            }
         }
 
         if (token == null) {
-            return null;
+            token = handler.getDefaultToken();
         }
 
         return token;



Mime
View raw message