geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r574424 - in /geronimo/sandbox/gshell/trunk: gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/ gshell-cli/src/main/resources/META-INF/plexus/ gshell-core/src/main/java/org/apache/geronimo/gshell/ gshell-core/src/main/java/org/apache/...
Date Tue, 11 Sep 2007 01:47:19 GMT
Author: jdillon
Date: Mon Sep 10 18:47:18 2007
New Revision: 574424

URL: http://svn.apache.org/viewvc?rev=574424&view=rev
Log:
Move the line to the branding, fixed up a few other bits

Modified:
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.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=574424&r1=574423&r2=574424&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
Mon Sep 10 18:47:18 2007
@@ -192,7 +192,7 @@
         //
 
         if (help) {
-            io.out.println(System.getProperty("program.name", branding.getName()) + " [options]
<command> [args]");
+            io.out.println(branding.getProgramName() + " [options] <command> [args]");
             io.out.println();
 
             Printer printer = new Printer(clp);

Modified: geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml?rev=574424&r1=574423&r2=574424&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml
Mon Sep 10 18:47:18 2007
@@ -80,6 +80,9 @@
                 <requirement>
                     <role>org.apache.geronimo.gshell.branding.VersionLoader</role>
                 </requirement>
+                <requirement>
+                    <role>jline.Terminal</role>
+                </requirement>
             </requirements>
         </component>
 

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java?rev=574424&r1=574423&r2=574424&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
Mon Sep 10 18:47:18 2007
@@ -219,15 +219,7 @@
 
         // Unless the user wants us to shut up, then display a nice welcome banner
         if (!io.isQuiet()) {
-            io.out.print(branding.getWelcomeBanner());
-
-            // HACK: If we can't tell, or have something bogus then use a reasonable default
-            int width = terminal.getTerminalWidth();
-            if (width < 1) {
-                width = 80;
-            }
-
-            io.out.println(StringUtils.repeat("-", width - 1));
+            io.out.println(branding.getWelcomeBanner());
         }
 
         // Check if there are args, and run them and then enter interactive

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java?rev=574424&r1=574423&r2=574424&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
Mon Sep 10 18:47:18 2007
@@ -85,6 +85,10 @@
     
     private File detectHomeDir() throws InitializationException {
         String homePath = branding.getProperty(Branding.HOME);
+
+        //
+        // FIXME: This is not very friendly to folks embedding the shell
+        //
         
         if (homePath == null) {
             throw new InitializationException("The '" + branding.getPropertyName(Branding.HOME)
+ "' property must be set for the shell to function correctly");

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java?rev=574424&r1=574423&r2=574424&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java
Mon Sep 10 18:47:18 2007
@@ -38,6 +38,8 @@
 
     String getDisplayName();
 
+    String getProgramName();
+
     String getAbout();
 
     String getVersion();

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java?rev=574424&r1=574423&r2=574424&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java
Mon Sep 10 18:47:18 2007
@@ -28,19 +28,28 @@
 import org.apache.geronimo.gshell.ansi.RenderWriter;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.util.StringUtils;
+import jline.Terminal;
+
+//
+// FIXME: Move this to a seperate module so that folks can omit this and use their own easily
+//
 
 /**
  * Provides the default branding for GShell.
  *
  * @version $Rev$ $Date$
  */
-@Component(role=Branding.class)
+@Component(role=Branding.class, hint="default")
 public class DefaultBranding
     implements Branding
 {
     @Requirement
     private VersionLoader versionLoader;
 
+    @Requirement
+    private Terminal terminal;
+
     public String getName() {
         return "gshell";
     }
@@ -49,6 +58,10 @@
         return "GShell";
     }
 
+    public String getProgramName() {
+        return System.getProperty("program.name", "gsh");
+    }
+
     public File getUserDirectory() {
         File userHome = new File(System.getProperty("user.home"));
 
@@ -84,33 +97,33 @@
         return versionLoader.getVersion();
     }
 
+    /*
+    private static final String[] BANNER = {
+        "   ____ ____  _          _ _ ",
+        "  / ___/ ___|| |__   ___| | |",
+        " | |  _\\___ \\| '_ \\ / _ \\ | |",
+        " | |_| |___) | | | |  __/ | |",
+        "  \\____|____/|_| |_|\\___|_|_|",
+    };
+    */
+
+    private static final String[] BANNER = {
+        "                          ,,                 ,,    ,,",
+        "   .g8\"\"\"bgd   .M\"\"\"bgd `7MM               `7MM  `7MM",
+        " .dP'     `M  ,MI    \"Y   MM                 MM    MM",
+        " dM'       `  `MMb.       MMpMMMb.  .gP\"Ya   MM    MM",
+        " MM             `YMMNq.   MM    MM ,M'   Yb  MM    MM",
+        " MM.    `7MMF'.     `MM   MM    MM 8M\"\"\"\"\"\"  MM    MM",
+        " `Mb.     MM  Mb     dM   MM    MM YM.    ,  MM    MM",
+        "   `\"bmmmdPY  P\"Ybmmd\"  .JMML  JMML.`Mbmmd'.JMML..JMML."
+    };
+
     public String getWelcomeBanner() {
         StringWriter writer = new StringWriter();
         PrintWriter out = new RenderWriter(writer);
         Buffer buff = new Buffer();
 
-        /*
-        String[] banner = {
-            "   ____ ____  _          _ _ ",
-            "  / ___/ ___|| |__   ___| | |",
-            " | |  _\\___ \\| '_ \\ / _ \\ | |",
-            " | |_| |___) | | | |  __/ | |",
-            "  \\____|____/|_| |_|\\___|_|_|",
-        };
-        */
-
-        String[] banner = {
-            "                          ,,                 ,,    ,,",
-            "   .g8\"\"\"bgd   .M\"\"\"bgd `7MM               `7MM  `7MM",
-            " .dP'     `M  ,MI    \"Y   MM                 MM    MM",
-            " dM'       `  `MMb.       MMpMMMb.  .gP\"Ya   MM    MM",
-            " MM             `YMMNq.   MM    MM ,M'   Yb  MM    MM",
-            " MM.    `7MMF'.     `MM   MM    MM 8M\"\"\"\"\"\"  MM    MM",
-            " `Mb.     MM  Mb     dM   MM    MM YM.    ,  MM    MM",
-            "   `\"bmmmdPY  P\"Ybmmd\"  .JMML  JMML.`Mbmmd'.JMML..JMML."
-        };
-
-        for (String line : banner) {
+        for (String line : BANNER) {
             buff.attrib(line, Code.CYAN);
             out.println(buff);
         }
@@ -119,6 +132,15 @@
         out.println(" @|bold GShell| (" + getVersion() + ")");
         out.println();
         out.println("Type '@|bold help|' for more information.");
+
+        // If we can't tell, or have something bogus then use a reasonable default
+        int width = terminal.getTerminalWidth();
+        if (width < 1) {
+            width = 80;
+        }
+        
+        out.print(StringUtils.repeat("-", width - 1));
+
         out.flush();
 
         return writer.toString();

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java?rev=574424&r1=574423&r2=574424&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java
Mon Sep 10 18:47:18 2007
@@ -27,6 +27,8 @@
 import org.codehaus.plexus.component.factory.ComponentFactory;
 import org.codehaus.plexus.component.factory.ComponentInstantiationException;
 import org.codehaus.plexus.component.repository.ComponentDescriptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Factory for producing {@link Terminal} instances.
@@ -37,7 +39,13 @@
 public class TerminalFactory
     extends AbstractComponentFactory
 {
+    protected Logger log = LoggerFactory.getLogger(getClass());
+
     public Object newInstance(ComponentDescriptor d, ClassRealm cr, PlexusContainer c) throws
ComponentInstantiationException {
-        return Terminal.getTerminal();
+        Terminal term =  Terminal.getTerminal();
+
+        log.debug("Handing out: {}", term);
+
+        return term;
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.java?rev=574424&r1=574423&r2=574424&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.java
Mon Sep 10 18:47:18 2007
@@ -19,13 +19,13 @@
 
 package org.apache.geronimo.gshell.lookup;
 
-import org.apache.geronimo.gshell.shell.Shell;
+import org.apache.geronimo.gshell.shell.Environment;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.InstantiationStrategy;
 import org.codehaus.plexus.component.factory.ComponentFactory;
 
 /**
- * Lookup factory for {@link Shell.Environment} instances.
+ * Lookup factory for {@link Environment} instances.
  *
  * @version $Rev$ $Date$
  */



Mime
View raw message