geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r669932 - in /geronimo/gshell/trunk: gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/ gshell-rapture/src/main/java/org/apac...
Date Fri, 20 Jun 2008 15:22:34 GMT
Author: jdillon
Date: Fri Jun 20 08:22:34 2008
New Revision: 669932

URL: http://svn.apache.org/viewvc?rev=669932&view=rev
Log:
More updates to the command documentation muck, drop support for 'help <command>' for
the moment while we figure out how to implement that

Added:
    geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandInfo.java
      - copied, changed from r669926, geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandCompleter.java
Modified:
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
    geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java
    geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineExecutor.java

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java?rev=669932&r1=669931&r2=669932&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
Fri Jun 20 08:22:34 2008
@@ -23,11 +23,10 @@
 import org.apache.geronimo.gshell.ansi.Renderer;
 import org.apache.geronimo.gshell.application.ApplicationManager;
 import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.Command;
 import org.apache.geronimo.gshell.command.CommandAction;
 import org.apache.geronimo.gshell.command.CommandContext;
 import org.apache.geronimo.gshell.command.CommandFactory;
-import org.apache.geronimo.gshell.command.Command;
-import org.apache.geronimo.gshell.command.CommandDocumenter;
 import org.apache.geronimo.gshell.command.annotation.CommandComponent;
 import org.apache.geronimo.gshell.command.annotation.Requirement;
 import org.apache.geronimo.gshell.io.IO;
@@ -60,7 +59,7 @@
     @Requirement
     private LayoutManager layoutManager;
 
-    @Argument(metaVar="COMMAND", description="Display help for COMMAND")
+    @Argument(metaVar="COMMAND", required=true, description="Display help for COMMAND")
     private String command;
 
     private Renderer renderer = new Renderer();
@@ -79,25 +78,8 @@
         assert context != null;
 
         IO io = context.getIo();
-        io.out.println();
-
-        if (command == null) {
-            displayAvailableCommands(io);
-        }
-        else {
-            Command cmd = commandFactory.create(command);
-
-            if (cmd == null) {
-                io.out.println("Command " + Renderer.encode(command, Code.BOLD) + " not found.");
-                io.out.println("Try " + Renderer.encode("help", Code.BOLD) + " for a list
of available commands.");
-                return Result.FAILURE;
-            }
-
-            CommandDocumenter documenter = cmd.getDocumenter();
-            // documenter.renderManual(info, io.out);
-
-            io.error("FIXME: Manual rendering is still pending, sorry");
-        }
+        
+        displayAvailableCommands(io);
 
         return Result.SUCCESS;
     }

Modified: geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java?rev=669932&r1=669931&r2=669932&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java
(original)
+++ geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java
Fri Jun 20 08:22:34 2008
@@ -45,6 +45,7 @@
         setIsolatedRealm(false);
         setInstantiationStrategy("singleton");
 
+        // Need to pass the command ID to the container
         XmlPlexusConfiguration config = new XmlPlexusConfiguration("configuration");
         config.addChild(new XmlPlexusConfiguration("commandId", model.getId()));
         setConfiguration(config);

Copied: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandInfo.java
(from r669926, geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandCompleter.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandInfo.java?p2=geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandInfo.java&p1=geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandCompleter.java&r1=669926&r2=669932&rev=669932&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandCompleter.java
(original)
+++ geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandInfo.java
Fri Jun 20 08:22:34 2008
@@ -19,30 +19,58 @@
 
 package org.apache.geronimo.gshell.rapture;
 
-import jline.Completor;
-import org.apache.geronimo.gshell.command.CommandCompleter;
-import org.apache.geronimo.gshell.command.CommandDocumenter;
 import org.apache.geronimo.gshell.command.CommandInfo;
-import org.codehaus.plexus.component.annotations.Component;
+import org.apache.geronimo.gshell.model.layout.AliasNode;
+import org.apache.geronimo.gshell.model.layout.CommandNode;
+import org.apache.geronimo.gshell.model.layout.Node;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * The default {@link CommandCompleter} component.
+ * The default {@link CommandInfo} implementation.
  *
  * @version $Rev$ $Date$
  */
-@Component(role=CommandDocumenter.class)
-public class DefaultCommandCompleter
-    implements CommandCompleter
+public class DefaultCommandInfo
+    implements CommandInfo
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    public Completor createCompletor(final CommandInfo info) {
-        assert info != null;
+    private final Node node;
 
-        // TODO:
+    public DefaultCommandInfo(final Node node) {
+        assert node != null;
+        this.node = node;
+    }
+
+    public String getId() {
+        if (node instanceof CommandNode) {
+            return ((CommandNode)node).getId();
+        }
+        else if (node instanceof AliasNode) {
+            return ((AliasNode)node).getCommand();
+        }
+
+        throw new IllegalStateException();
+    }
+
+    public String getName() {
+        if (node instanceof AliasNode) {
+            return ((AliasNode)node).getCommand();
+        }
+
+        return node.getName();
+    }
+
+    public String getAlias() {
+        if (node instanceof AliasNode) {
+            return node.getName();
+        }
+
+        return null;
+    }
 
+    public String getPath() {
         throw new Error();
     }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineExecutor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineExecutor.java?rev=669932&r1=669931&r2=669932&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineExecutor.java
(original)
+++ geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineExecutor.java
Fri Jun 20 08:22:34 2008
@@ -83,7 +83,7 @@
     @Requirement
     private CommandLineBuilder commandLineBuilder;
 
-    private ShellContext env;
+    private ShellContext shellContext;
 
     public DefaultCommandLineExecutor() {}
     
@@ -102,7 +102,7 @@
     public void initialize() throws InitializationException {
         assert applicationManager != null;
         
-        this.env = applicationManager.getContext().getEnvironment();
+        this.shellContext = applicationManager.getContext().getEnvironment();
     }
 
     public Object execute(final String line) throws Exception {
@@ -138,7 +138,7 @@
 
         log.info("Executing (Object...): [{}]", Arguments.asString(args));
 
-        return execute(String.valueOf(args[0]), Arguments.shift(args), env.getIo());
+        return execute(String.valueOf(args[0]), Arguments.shift(args), shellContext.getIo());
     }
 
     public Object execute(final String path, final Object[] args) throws Exception {
@@ -147,7 +147,7 @@
 
         log.info("Executing ({}): [{}]", path, Arguments.asString(args));
 
-        return execute(path, args, env.getIo());
+        return execute(path, args, shellContext.getIo());
     }
 
     public Object execute(final Object[][] commands) throws Exception {
@@ -158,17 +158,17 @@
         PipedOutputStream pos = null;
 
         for (int i = 0; i < ios.length; i++) {
-            InputStream is = (i == 0) ? env.getIo().inputStream : new PipedInputStream(pos);
+            InputStream is = (i == 0) ? shellContext.getIo().inputStream : new PipedInputStream(pos);
             OutputStream os;
 
             if (i == ios.length - 1) {
-                os = env.getIo().outputStream;
+                os = shellContext.getIo().outputStream;
             }
             else {
                 os = pos = new PipedOutputStream();
             }
 
-            ios[i] = new IO(is, new PrintStream(os), env.getIo().errorStream);
+            ios[i] = new IO(is, new PrintStream(os), shellContext.getIo().errorStream);
         }
 
         Thread[] threads = new Thread[commands.length];
@@ -230,7 +230,7 @@
     protected Object execute(final String path, final Object[] args, final IO io) throws
Exception {
         log.debug("Executing");
 
-        final String searchPath = (String) env.getVariables().get(LayoutManager.COMMAND_PATH);
+        final String searchPath = (String) shellContext.getVariables().get(LayoutManager.COMMAND_PATH);
         log.debug("Search path: {}", searchPath);
 
         final Node node = layoutManager.findNode(path, searchPath);
@@ -250,7 +250,7 @@
         // Setup the command context and pass it to the command instance
         CommandContext context = new CommandContext() {
             // Command instances get their own namespace with defaults from the current
-            final Variables vars = new DefaultVariables(env.getVariables());
+            final Variables vars = new DefaultVariables(shellContext.getVariables());
 
             CommandInfo info;
 
@@ -268,36 +268,7 @@
 
             public CommandInfo getInfo() {
                 if (info == null) {
-                    info = new CommandInfo()
-                    {
-                        public String getId() {
-                            return id;
-                        }
-
-                        public String getName() {
-                            if (node instanceof AliasNode) {
-                                return ((AliasNode)node).getCommand();
-                            }
-
-                            return node.getName();
-                        }
-
-                        public String getAlias() {
-                            if (node instanceof AliasNode) {
-                                return node.getName();
-                            }
-
-                            return null;
-                        }
-
-                        public String getPath() {
-                            //
-                            // TODO:
-                            //
-                            
-                            return null;
-                        }
-                    };
+                    info = new DefaultCommandInfo(node);
                 }
 
                 return info;



Mime
View raw message