geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r573938 - in /geronimo/sandbox/gshell/trunk: gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/ gshell-command-api/src/main/java/org/apache/geronimo/gshell/ gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/ gshell-c...
Date Sun, 09 Sep 2007 00:57:53 GMT
Author: jdillon
Date: Sat Sep  8 17:57:52 2007
New Revision: 573938

URL: http://svn.apache.org/viewvc?rev=573938&view=rev
Log:
Bring the banner back, hook up ~/.gshell/gshell.history, ~/.gshell/gshell.profile and ~/.gshell/gshell.rc
handling
Move the Shell interfaces over to gshell-command-api
Rename our *Impls to Default* to be more plexus-like

Added:
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java
  (contents, props changed)
      - copied, changed from r573906, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java
  (contents, props changed)
      - copied, changed from r573906, geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
  (contents, props changed)
      - copied, changed from r573906, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
  (contents, props changed)
      - copied, changed from r573906, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java
  (contents, props changed)
      - copied, changed from r573906, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManagerImpl.java
Removed:
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManagerImpl.java
Modified:
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java

Modified: geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=573938&r1=573937&r2=573938&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
Sat Sep  8 17:57:52 2007
@@ -21,10 +21,13 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
 
+import jline.History;
 import jline.Terminal;
 import org.apache.geronimo.gshell.ErrorNotification;
 import org.apache.geronimo.gshell.ExitNotification;
@@ -44,6 +47,7 @@
 import org.codehaus.plexus.DefaultPlexusContainer;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.classworlds.ClassWorld;
+import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -179,17 +183,15 @@
         }
     }
 
-    private void loadUserScript(final String fileName) {
+    private void loadUserScript(final Shell shell, final String fileName) throws Exception
{
         assert fileName != null;
 
         File file = new File(getUserStateDirectory(), fileName);
 
         if (file.exists()) {
-            //
-            // TODO: Run the 'source' comamnd for the filename
-            //
-
             log.debug("Loading user-script: {}", file);
+
+            shell.execute("source", file.toURI().toURL());
         }
     }
 
@@ -235,7 +237,25 @@
             }
         }
     }
-    
+
+    private String getBanner() {
+        StringWriter writer = new StringWriter();
+        PrintWriter out = new PrintWriter(writer);
+
+        out.println("   ____ ____  _          _ _ ");
+        out.println("  / ___/ ___|| |__   ___| | |");
+        out.println(" | |  _\\___ \\| '_ \\ / _ \\ | |");
+        out.println(" | |_| |___) | | | |  __/ | |");
+        out.println("  \\____|____/|_| |_|\\___|_|_|");
+        out.println();
+        out.println(" @|bold GShell| (" + Version.getInstance() + ")");
+        out.println();
+        out.println("Type '@|bold help|' for help.");
+        out.flush();
+
+        return writer.toString();
+    }
+
     private int execute(final String[] args) throws Exception {
         // Its okay to use logging now
         log = LoggerFactory.getLogger(getClass());
@@ -273,9 +293,11 @@
 
         try {
             //
-            // TODO: Load user profile here
+            // TODO: Get the name from the branding theme
             //
 
+            loadUserScript(shell, "gshell.profile");
+
             //
             // TODO: Pass interactive flags (maybe as property) so gshell knows what modfooe
it is
             //
@@ -288,11 +310,12 @@
             else if (interactive) {
                 log.debug("Starting interactive console");
 
-
                 //
-                // TODO: Load user rc here
+                // TODO: Get the name from the branding theme
                 //
 
+                loadUserScript(shell, "gshell.rc");
+
                 IO io = shell.getIO();
 
                 Console.Executor executor = new Console.Executor() {
@@ -301,6 +324,10 @@
                             /* Object result =*/ shell.execute(line);
                         }
                         catch (ExitNotification n) {
+                            //
+                            // FIXME: This eats up the exit code we are to use...
+                            //
+
                             return Result.STOP;
                         }
 
@@ -326,17 +353,34 @@
                 });
 
                 //
-                // TODO: Setup history here
+                // TODO: Get the name from the branding theme
                 //
+                
+                runner.setHistory(new History());
+                runner.setHistoryFile(new File(getUserStateDirectory(), "gshell.history"));
+
 
                 // Check if there are args, and run them and then enter interactive
                 if (args.length != 0) {
                     shell.execute(args);
                 }
 
-                //
-                // TODO: Display the banner here
-                //
+                if (!io.isQuiet()) {
+                    //
+                    // TODO: Use a plugable branding theme object here to get the welcome
banner text...
+                    //
+                    
+                    io.out.println(getBanner());
+
+                    int width = term.getTerminalWidth();
+
+                    // If we can't tell, or have something bogus then use a reasonable default
+                    if (width < 1) {
+                        width = 80;
+                    }
+
+                    io.out.println(StringUtils.repeat("-", width - 1));
+                }
 
                 runner.run();
             }
@@ -414,7 +458,7 @@
                     // will set an exit code through the proper channels
 
                     io.err.println();
-                    io.err.println("WARNING: Abnormal JVM shutdown detected");
+                    io.err.println("@|red WARNING:| Abnormal JVM shutdown detected");
                 }
 
                 io.flush();

Copied: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java
(from r573906, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java?p2=geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java&r1=573906&r2=573938&rev=573938&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java
Sat Sep  8 17:57:52 2007
@@ -29,14 +29,6 @@
  */
 public interface Shell
 {
-    //
-    // FIXME: Move to gshell-api
-    //
-
-    //
-    // TODO: Just expose the Enviroment
-    //
-
     IO getIO();
 
     Variables getVariables();

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java
(from r573906, geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java?p2=geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java&p1=geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java&r1=573906&r2=573938&rev=573938&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java
Sat Sep  8 17:57:52 2007
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.command;
+package org.apache.geronimo.gshell;
 
 import java.io.File;
 

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java?rev=573938&r1=573937&r2=573938&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java
Sat Sep  8 17:57:52 2007
@@ -26,7 +26,7 @@
 /**
  * Provides commands with the context of its execution.
  *
- * @version $Rev: 572562 $ $Date: 2007-09-04 00:43:23 -0700 (Tue, 04 Sep 2007) $
+ * @version $Rev$ $Date$
  */
 public interface CommandContext
 {
@@ -35,11 +35,4 @@
     Variables getVariables();
 
     CommandDescriptor getCommandDescriptor();
-
-
-    //
-    // TODO: Split up the Shell's bits from the commands bits maybe?  Or expose a ShellInfo
object for these bits maybe?
-    //
-
-    // File getHomeDir();
 }

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
(from r573906, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java&r1=573906&r2=573938&rev=573938&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
Sat Sep  8 17:57:52 2007
@@ -42,8 +42,8 @@
  *
  * @version $Rev$ $Date$
  */
-@Component(role=Shell.class)
-public class ShellImpl
+@Component(role=Shell.class, hint="default")
+public class DefaultShell
     implements Shell, Initializable
 {
     private Logger log = LoggerFactory.getLogger(getClass());

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
(from r573906, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java&r1=573906&r2=573938&rev=573938&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
Sat Sep  8 17:57:52 2007
@@ -22,7 +22,7 @@
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.geronimo.gshell.command.ShellInfo;
+import org.apache.geronimo.gshell.ShellInfo;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
@@ -34,8 +34,8 @@
  *
  * @version $Rev$ $Date$
  */
-@Component(role=ShellInfo.class)
-public class ShellInfoImpl
+@Component(role=ShellInfo.class, hint="default")
+public class DefaultShellInfo
     implements ShellInfo, Initializable
 {
     private final Logger log = LoggerFactory.getLogger(getClass());

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java
(from r573906, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManagerImpl.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManagerImpl.java&r1=573906&r2=573938&rev=573938&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManagerImpl.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java
Sat Sep  8 17:57:52 2007
@@ -25,7 +25,7 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 
-import org.apache.geronimo.gshell.command.ShellInfo;
+import org.apache.geronimo.gshell.ShellInfo;
 import org.apache.geronimo.gshell.command.descriptor.CommandDescriptor;
 import org.apache.geronimo.gshell.layout.model.Layout;
 import org.apache.geronimo.gshell.plugin.PluginCollector;
@@ -41,8 +41,8 @@
  *
  * @version $Rev$ $Date$
  */
-@Component(role=LayoutManager.class)
-public class LayoutManagerImpl
+@Component(role=LayoutManager.class, hint="default")
+public class DefaultLayoutManager
     implements LayoutManager, Initializable
 {
     private final Logger log = LoggerFactory.getLogger(getClass());

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message