geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r700117 - in /geronimo/gshell/trunk: gshell-assembly/src/main/underlay/etc/ gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/ gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ gshell-wisdom/g...
Date Mon, 29 Sep 2008 12:57:26 GMT
Author: jdillon
Date: Mon Sep 29 05:57:24 2008
New Revision: 700117

URL: http://svn.apache.org/viewvc?rev=700117&view=rev
Log:
Hook back up a custom branding which has nice figlet/ansi muck

Added:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/branding/
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/branding/GShellBranding.java
  (with props)
Modified:
    geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
    geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AboutAction.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java

Modified: geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml?rev=700117&r1=700116&r2=700117&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml (original)
+++ geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml Mon Sep 29
05:57:24 2008
@@ -98,8 +98,6 @@
         </pluginGroup>
     </pluginGroups>
 
-    <branding>
-        <name>gshell</name>
-    </branding>
+    <branding class="org.apache.geronimo.gshell.wisdom.branding.GShellBranding"/>
 
 </application>
\ No newline at end of file

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=700117&r1=700116&r2=700117&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
Mon Sep 29 05:57:24 2008
@@ -65,6 +65,10 @@
     // TODO: Add --application and --settings
     //
 
+    //
+    // TODO: Add --file <file>, which will run: source <file> 
+    //
+
     @Option(name="-h", aliases={"--help"}, requireOverride=true)
     private boolean help;
 
@@ -218,10 +222,7 @@
             ApplicationModel applicationModel = new ApplicationModelLocator().locate();
             builder.setApplicationModel(applicationModel);
 
-            //
-            // HACK: --help and --version need access to the application's information, so
we have to handle these options late
-            //
-            
+            // --help and --version need access to the application's information, so we have
to handle these options late
             if (help|version) {
                 if (help) {
                     Printer printer = new Printer(clp);

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AboutAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AboutAction.java?rev=700117&r1=700116&r2=700117&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AboutAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AboutAction.java
Mon Sep 29 05:57:24 2008
@@ -25,6 +25,7 @@
 import org.apache.geronimo.gshell.command.CommandContext;
 import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.model.application.ApplicationModel;
+import org.apache.geronimo.gshell.model.application.Branding;
 import org.springframework.beans.factory.annotation.Autowired;
 
 /**
@@ -45,7 +46,8 @@
         assert applicationManager != null;
         Application app = applicationManager.getApplication();
         ApplicationModel model = app.getModel();
-
+        Branding branding = app.getModel().getBranding();
+        
         String id = app.getId();
         String name = model.getName();
 
@@ -58,6 +60,9 @@
 
         io.info("{}", model.getVersion());
 
+        io.out.println();
+        io.out.println(branding.getAboutMessage());
+
         //
         // TODO: Add more options to get specific details out.  Hook up the branding muck
here too.
         //

Added: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/branding/GShellBranding.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/branding/GShellBranding.java?rev=700117&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/branding/GShellBranding.java
(added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/branding/GShellBranding.java
Mon Sep 29 05:57:24 2008
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.wisdom.branding;
+
+import org.apache.geronimo.gshell.ansi.Buffer;
+import org.apache.geronimo.gshell.ansi.Code;
+import org.apache.geronimo.gshell.ansi.RenderWriter;
+import org.apache.geronimo.gshell.model.application.Branding;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * A custom branding for the default GShell application.
+ *
+ * @version $Rev$ $Date$
+ */
+public class GShellBranding
+    extends Branding
+{
+    public GShellBranding() {}
+
+    @Override
+    public String getName() {
+        return "gshell";
+    }
+
+    @Override
+    public void setName(String name) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public String getDisplayName() {
+        return "GShell";
+    }
+
+    @Override
+    public void setDisplayName(String displayName) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public String getProgramName() {
+        return "gsh";
+    }
+    
+    @Override
+    public void setProgramName(String programName) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public String getAboutMessage() {
+        StringWriter writer = new StringWriter();
+        PrintWriter out = new RenderWriter(writer);
+
+        out.println("For information about @|cyan GShell|, visit:");
+        out.println("    @|bold http://gshell.org| ");
+        out.flush();
+
+        return writer.toString();
+    }
+
+    @Override
+    public void setAboutMessage(final String aboutMessage) {
+        throw new UnsupportedOperationException();
+    }
+
+    /*
+    // Figlet font name: ???
+    private static final String[] BANNER = {
+        "   ____ ____  _          _ _ ",
+        "  / ___/ ___|| |__   ___| | |",
+        " | |  _\\___ \\| '_ \\ / _ \\ | |",
+        " | |_| |___) | | | |  __/ | |",
+        "  \\____|____/|_| |_|\\___|_|_|",
+    };
+    */
+
+    // Figlet font name: Georgia11
+    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."
+    };
+
+    /*
+    // Figlet font name: Georgia11
+    private static final String[] BANNER = {
+        "                          ,,                 ,,    ,,             ..",
+        "   .g8\"\"\"bgd   .M\"\"\"bgd `7MM               `7MM  `7MM              `bq",
+        " .dP'     `M  ,MI    \"Y   MM                 MM    MM                YA",
+        " dM'       `  `MMb.       MMpMMMb.  .gP\"Ya   MM    MM                `Mb",
+        " MM             `YMMNq.   MM    MM ,M'   Yb  MM    MM      mmmmmmmmm  8M",
+        " MM.    `7MMF'.     `MM   MM    MM 8M\"\"\"\"\"\"  MM    MM                 8M",
+        " `Mb.     MM  Mb     dM   MM    MM YM.    ,  MM    MM      mmmmmmmmm ,M9",
+        "   `\"bmmmdPY  P\"Ybmmd\"  .JMML  JMML.`Mbmmd'.JMML..JMML.              dM",
+        "                                                                   .pY"
+    };
+    */
+
+    @Override
+    public String getWelcomeMessage() {
+        StringWriter writer = new StringWriter();
+        PrintWriter out = new RenderWriter(writer);
+        Buffer buff = new Buffer();
+
+        for (String line : BANNER) {
+            buff.attrib(line, Code.CYAN);
+            out.println(buff);
+        }
+
+        out.println();
+        out.print(" @|bold GShell| (");
+        out.print(getParent().getVersion());
+        out.println(")");
+        out.println();
+        out.println("Type '@|bold help|' for more information.");
+
+        out.flush();
+
+        return writer.toString();
+    }
+
+    @Override
+    public void setWelcomeMessage(String welcomeMessage) {
+        throw new UnsupportedOperationException();
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/branding/GShellBranding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/branding/GShellBranding.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/branding/GShellBranding.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java?rev=700117&r1=700116&r2=700117&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
Mon Sep 29 05:57:24 2008
@@ -43,6 +43,7 @@
 import org.apache.geronimo.gshell.shell.ShellContext;
 import org.apache.geronimo.gshell.wisdom.application.ApplicationConfiguredEvent;
 import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -214,12 +215,17 @@
         if (!io.isQuiet()) {
             String message = branding.getWelcomeMessage();
             if (message != null) {
-                io.out.println(message);
-            }
+                io.out.print(message);
 
-            //
-            // TODO: Render a nice line here if the branding has some property configured
to enable it (move that bit out of branding's job)
-            //
+                // If we can't tell, or have something bogus then use a reasonable default
+                int width = io.getTerminal().getTerminalWidth();
+                if (width < 1) {
+                    width = 80;
+                }
+                io.out.println(StringUtils.repeat("-", width - 1));
+
+                io.out.flush();
+            }
         }
 
         // Check if there are args, and run them and then enter interactive



Mime
View raw message