geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r699021 - in /geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom: alias/AliasCommand.java command/CommandDocumenterImpl.java command/CommandDocumenterSupport.java
Date Thu, 25 Sep 2008 16:57:43 GMT
Author: jdillon
Date: Thu Sep 25 09:57:43 2008
New Revision: 699021

URL: http://svn.apache.org/viewvc?rev=699021&view=rev
Log:
Creating support for documenters
Starting to wire up the components to make AliasCommand work

Added:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java
  (contents, props changed)
      - copied, changed from r699018, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java
Modified:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java?rev=699021&r1=699020&r2=699021&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java
Thu Sep 25 09:57:43 2008
@@ -19,8 +19,13 @@
 
 package org.apache.geronimo.gshell.wisdom.alias;
 
-import org.apache.geronimo.gshell.command.CommandResult;
-import org.apache.geronimo.gshell.shell.ShellContext;
+import jline.Completor;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandCompleter;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.i18n.MessageSource;
+import org.apache.geronimo.gshell.notification.Notification;
+import org.apache.geronimo.gshell.wisdom.command.CommandDocumenterSupport;
 import org.apache.geronimo.gshell.wisdom.command.CommandSupport;
 
 /**
@@ -41,15 +46,54 @@
 
         this.name = name;
         this.target = target;
+
+        setAction(new AliasCommandAction());
+        setDocumenter(new AliasCommandDocumenter());
+        setCompleter(new AliasCommandCompleter());
+        setMessages(new AliasCommandMessageSource());
+    }
+
+    private class AliasCommandAction
+        implements CommandAction
+    {
+        public Object execute(final CommandContext context) throws Notification, Exception
{
+            return null;
+        }
     }
-    
-    @Override
-    public CommandResult execute(final ShellContext context, final Object[] args) {
-        assert context != null;
-        assert args != null;
 
-        log.debug("Executing");
+    private class AliasCommandDocumenter
+        extends CommandDocumenterSupport
+    {
+        public String getName() {
+            return null;
+        }
+
+        public String getDescription() {
+            return null;
+        }
+
+        protected String getManual() {
+            return null;
+        }
+    }
+
+    private class AliasCommandCompleter
+        implements CommandCompleter
+    {
+        public Completor createCompletor() {
+            return null;
+        }
+    }
 
-        throw new Error("not implemented");
+    private class AliasCommandMessageSource
+        implements MessageSource
+    {
+        public String getMessage(final String code) {
+            return null;
+        }
+
+        public String format(final String code, final Object... args) {
+            return null;
+        }
     }
 }

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java?rev=699021&r1=699020&r2=699021&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java
Thu Sep 25 09:57:43 2008
@@ -19,38 +19,20 @@
 
 package org.apache.geronimo.gshell.wisdom.command;
 
-import org.apache.geronimo.gshell.ansi.Code;
-import org.apache.geronimo.gshell.ansi.Renderer;
-import org.apache.geronimo.gshell.clp.CommandLineProcessor;
-import org.apache.geronimo.gshell.clp.Printer;
-import org.apache.geronimo.gshell.command.Command;
-import org.apache.geronimo.gshell.command.CommandAction;
-import org.apache.geronimo.gshell.command.CommandAware;
 import org.apache.geronimo.gshell.command.CommandDocumenter;
-import org.apache.geronimo.gshell.i18n.PrefixingMessageSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.PrintWriter;
 
 /**
- * The default {@link CommandDocumenter} component.
+ * {@link CommandDocumenter} component.
  *
  * @version $Rev$ $Date$
  */
 public class CommandDocumenterImpl
-    implements CommandDocumenter, CommandAware
+    extends CommandDocumenterSupport
 {
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
-    private Command command;
-
     private String name;
 
     private String description;
 
-    private Renderer renderer = new Renderer();
-
     public String getName() {
         if (name == null) {
             name = getCommand().getMessages().getMessage("command.name");
@@ -73,71 +55,7 @@
         this.description = description;
     }
 
-    private String getManual() {
+    protected String getManual() {
         return getCommand().getMessages().getMessage("command.manual");
     }
-
-    //
-    // CommandAware
-    //
-
-    public void setCommand(final Command command) {
-        assert command != null;
-
-        this.command = command;
-    }
-
-    private Command getCommand() {
-        assert command != null;
-
-        return command;
-    }
-
-    //
-    // CommandDocumenter
-    //
-
-    public void renderUsage(final PrintWriter out) {
-        assert out != null;
-
-        log.debug("Rendering command usage");
-        
-        CommandLineProcessor clp = new CommandLineProcessor();
-        
-        // Attach our helper to inject --help
-        HelpSupport help = new HelpSupport();
-        clp.addBean(help);
-
-        // And then the beans options
-        CommandAction action = getCommand().getAction();
-        clp.addBean(action);
-
-        // Render the help
-        out.println(getDescription());
-        out.println();
-
-        Printer printer = new Printer(clp);
-        printer.setMessageSource(new PrefixingMessageSource(getCommand().getMessages(), "command."));
-        printer.printUsage(out, getName());
-    }
-
-    public void renderManual(final PrintWriter out) {
-        assert out != null;
-
-        log.debug("Rendering command manual");
-
-        out.println(renderer.render(Renderer.encode("NAME", Code.BOLD)));
-        out.print("  ");
-        out.println(getName());
-        out.println();
-
-        out.println(renderer.render(Renderer.encode("DESCRIPTION", Code.BOLD)));
-        out.print("  ");
-        out.println(getDescription());
-        out.println();
-
-        out.println(renderer.render(Renderer.encode("MANUAL", Code.BOLD)));
-        out.println(getManual());
-        out.println();
-    }
 }
\ No newline at end of file

Copied: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java
(from r699018, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java?p2=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java&r1=699018&r2=699021&rev=699021&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java
Thu Sep 25 09:57:43 2008
@@ -34,49 +34,21 @@
 import java.io.PrintWriter;
 
 /**
- * The default {@link CommandDocumenter} component.
+ * Support for {@link CommandDocumenter} components.
  *
  * @version $Rev$ $Date$
  */
-public class CommandDocumenterImpl
+public abstract class CommandDocumenterSupport
     implements CommandDocumenter, CommandAware
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     private Command command;
 
-    private String name;
-
-    private String description;
-
     private Renderer renderer = new Renderer();
 
-    public String getName() {
-        if (name == null) {
-            name = getCommand().getMessages().getMessage("command.name");
-        }
-        return name;
-    }
-
-    public void setName(final String name) {
-        this.name = name;
-    }
-
-    public String getDescription() {
-        if (description == null) {
-            description = getCommand().getMessages().getMessage("command.description");
-        }
-        return description;
-    }
-
-    public void setDescription(final String description) {
-        this.description = description;
-    }
-
-    private String getManual() {
-        return getCommand().getMessages().getMessage("command.manual");
-    }
-
+    protected abstract String getManual();
+    
     //
     // CommandAware
     //
@@ -87,7 +59,7 @@
         this.command = command;
     }
 
-    private Command getCommand() {
+    protected Command getCommand() {
         assert command != null;
 
         return command;
@@ -101,9 +73,9 @@
         assert out != null;
 
         log.debug("Rendering command usage");
-        
+
         CommandLineProcessor clp = new CommandLineProcessor();
-        
+
         // Attach our helper to inject --help
         HelpSupport help = new HelpSupport();
         clp.addBean(help);

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message