geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r572552 - in /geronimo/sandbox/gshell/trunk: gshell-assembly/ gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/ gshell-commands/ gshell-commands/gshell-bsf/ gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands...
Date Tue, 04 Sep 2007 06:50:39 GMT
Author: jdillon
Date: Mon Sep  3 23:50:37 2007
New Revision: 572552

URL: http://svn.apache.org/viewvc?rev=572552&view=rev
Log:
Bring the script command back to life

Removed:
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/InteractiveInterpreter.java
Modified:
    geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java
    geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/Notification.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/JLineConsole.java

Modified: geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml?rev=572552&r1=572551&r2=572552&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml Mon Sep  3 23:50:37 2007
@@ -69,20 +69,6 @@
             <version>${pom.version}</version>
         </dependency>
 
-        <!--
-        <dependency>
-            <groupId>org.apache.geronimo.gshell.commands</groupId>
-            <artifactId>gshell-bsf</artifactId>
-            <version>${pom.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.geronimo.gshell.commands</groupId>
-            <artifactId>gshell-vfs</artifactId>
-            <version>${pom.version}</version>
-        </dependency>
-        -->
-
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
@@ -117,5 +103,31 @@
             </plugin>
         </plugins>
     </build>
+
+    <profiles>
+        <profile>
+            <id>full</id>
+            
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.geronimo.gshell.commands</groupId>
+                    <artifactId>gshell-bsf</artifactId>
+                    <version>${pom.version}</version>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.beanshell</groupId>
+                    <artifactId>bsh</artifactId>
+                    <version>2.0b4</version>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.geronimo.gshell.commands</groupId>
+                    <artifactId>gshell-vfs</artifactId>
+                    <version>${pom.version}</version>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
 
 </project>

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=572552&r1=572551&r2=572552&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  3 23:50:37 2007
@@ -224,6 +224,8 @@
         else if (interactive) {
             log.debug("Starting interactive console");
 
+            IO io = shell.getIO();
+            
             Console.Executor executor = new Console.Executor() {
                 public Result execute(String line) throws Exception {
                     try {
@@ -237,7 +239,7 @@
                 }
             };
 
-            JLineConsole runner = new JLineConsole(executor, shell);
+            JLineConsole runner = new JLineConsole(executor, io);
 
             runner.setErrorHandler(new Console.ErrorHandler() {
                 public Result handleError(Throwable error) {

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml?rev=572552&r1=572551&r2=572552&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml Mon Sep  3 23:50:37 2007
@@ -38,9 +38,20 @@
     </description>
     
     <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.gshell</groupId>
+            <artifactId>gshell-api</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gshell</groupId>
+            <artifactId>gshell-console</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
         <!--
-            FIXME: Need to abstract InteractiveConsole and move it to API, until
-                   then depend on core.
+        NOTE: Currently only here to pick some the Jline conosole bits which should eventually
be relocated.
         -->
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java?rev=572552&r1=572551&r2=572552&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java
Mon Sep  3 23:50:37 2007
@@ -21,9 +21,11 @@
 
 import org.apache.bsf.BSFEngine;
 import org.apache.bsf.BSFManager;
+import org.apache.geronimo.gshell.IO;
+import org.apache.geronimo.gshell.JLineConsole;
 import org.apache.geronimo.gshell.clp.Option;
 import org.apache.geronimo.gshell.command.CommandSupport;
-import org.apache.geronimo.gshell.console.JLineConsole;
+import org.apache.geronimo.gshell.console.Console;
 
 /**
  * Provides generic scripting language integration via <a href="http://http://jakarta.apache.org/bsf">BSF</a>.
@@ -33,13 +35,23 @@
 public class ScriptCommand
     extends CommandSupport
 {
-    @Option(name="l", aliases={"--language"}, required=true, description="Specify the scripting
language")
     private String language;
 
-    @Option(name="i", aliases={"--interactive"}, description="Run interactive mode")
+    @Option(name="-l", aliases={"--language"}, required=true, description="Specify the scripting
language")
+    private void setLanguage(final String language) {
+        assert language != null;
+        
+        if (!BSFManager.isLanguageRegistered(language)) {
+            throw new RuntimeException("Language is not registered: " + language);
+        }
+
+        this.language = language;
+    }
+
+    @Option(name="-i", aliases={"--interactive"}, description="Run interactive mode")
     private boolean interactive;
 
-    @Option(name="e", aliases={"--expression"}, description="Evaluate the given expression")
+    @Option(name="-e", aliases={"--expression"}, description="Evaluate the given expression")
     private String expression;
 
     public ScriptCommand() {
@@ -51,10 +63,6 @@
         // TODO: When given a file/url, try to figure out language from ext if language not
given
         //
 
-        if (!BSFManager.isLanguageRegistered(language)) {
-            throw new RuntimeException("Language is not registered: " + language);
-        }
-
         BSFManager manager = new BSFManager();
         final BSFEngine engine = manager.loadScriptingEngine(language);
 
@@ -75,8 +83,39 @@
         }
 
         if (this.interactive) {
-            InteractiveInterpreter interp = new InteractiveInterpreter(new JLineConsole(getIO()),
engine, language);
-            interp.run();
+            log.debug("Starting interactive console...");
+            
+            IO io = getIO();
+            
+            Console.Executor executor = new Console.Executor() {
+                public Result execute(final String line) throws Exception {
+                    // Execute unless the line is just blank
+                    
+                    if (!line.trim().equals("")) {
+                        engine.exec("<unknown>", 1, 1, line);
+                    }
+
+                    return Result.CONTINUE;
+                }
+            };
+
+            JLineConsole runner = new JLineConsole(executor, io);
+
+            runner.setErrorHandler(new Console.ErrorHandler() {
+                public Result handleError(final Throwable error) {
+                    log.error("Script evalutation failed: " + error, error);
+
+                    return Result.CONTINUE;
+                }
+            });
+
+            runner.setPrompter(new Console.Prompter() {
+                public String prompt() {
+                    return language + "> ";
+                }
+            });
+
+            runner.run();
         }
 
         return SUCCESS;

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml?rev=572552&r1=572551&r2=572552&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml Mon Sep  3 23:50:37 2007
@@ -50,9 +50,7 @@
     <modules>
         <module>gshell-builtins</module>
         <module>gshell-optional</module>
-        <!--
         <module>gshell-bsf</module>
-        -->
         <module>gshell-vfs</module>
     </modules>
     

Modified: geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/Notification.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/Notification.java?rev=572552&r1=572551&r2=572552&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/Notification.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/Notification.java
Mon Sep  3 23:50:37 2007
@@ -29,8 +29,16 @@
 {
     ///CLOVER:OFF
 
+    public Notification(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+
     public Notification(final String msg) {
         super(msg);
+    }
+
+    public Notification(final Throwable cause) {
+        super(cause);
     }
 
     public Notification() {

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/JLineConsole.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/JLineConsole.java?rev=572552&r1=572551&r2=572552&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/JLineConsole.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/JLineConsole.java
Mon Sep  3 23:50:37 2007
@@ -44,10 +44,11 @@
     // TODO: Pass in the terminal instance to be used
     //
     
-    public JLineConsole(final Executor executor, final Shell shell) throws IOException {
+    public JLineConsole(final Executor executor, final IO io) throws IOException {
         super(executor);
 
-        IO io = shell.getIO();
+        assert io != null;
+
         this.reader = new ConsoleReader(io.inputStream, new PrintWriter(io.outputStream,
true));
 
         // this.completor = new CommandsMultiCompletor()



Mime
View raw message