Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 51407 invoked from network); 5 Jun 2006 07:43:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 5 Jun 2006 07:43:21 -0000 Received: (qmail 50034 invoked by uid 500); 5 Jun 2006 07:43:20 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 49892 invoked by uid 500); 5 Jun 2006 07:43:20 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 49877 invoked by uid 99); 5 Jun 2006 07:43:19 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jun 2006 00:43:19 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jun 2006 00:43:19 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 1CCF71A983A; Mon, 5 Jun 2006 00:42:59 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r411702 - in /geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell: InteractiveShell.java Shell.java console/InteractiveConsole.java Date: Mon, 05 Jun 2006 07:42:58 -0000 To: scm@geronimo.apache.org From: jdillon@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060605074259.1CCF71A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: jdillon Date: Mon Jun 5 00:42:57 2006 New Revision: 411702 URL: http://svn.apache.org/viewvc?rev=411702&view=rev Log: Hooked up semi-functional console tab completion when using JLine Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveShell.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/console/InteractiveConsole.java Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveShell.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveShell.java?rev=411702&r1=411701&r2=411702&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveShell.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveShell.java Mon Jun 5 00:42:57 2006 @@ -18,11 +18,16 @@ import org.apache.geronimo.gshell.console.InteractiveConsole; import org.apache.geronimo.gshell.console.Console; +import org.apache.geronimo.gshell.console.JLineConsole; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.io.IOException; +import jline.ConsoleReader; +import jline.SimpleCompletor; +import jline.CandidateListCompletionHandler; + /** * Provides the user-interaction bits for Shell. * @@ -38,16 +43,16 @@ // Seems like that is what we are doing so far anyways (sub-classing that is) // - public InteractiveShell(final Console console, final Shell gshell) throws IOException { + public InteractiveShell(final Console console, final Shell shell) throws IOException { super(console, new InteractiveConsole.Executor() { public Result execute(final String line) throws Exception { assert line != null; // Execute unless the line is just blank - if (!line.trim().equals("")) { + if (line.trim().length() != 0) { try { - gshell.execute(line); + shell.execute(line); } catch (ExitNotification n) { return Result.STOP; @@ -66,5 +71,20 @@ return "> "; } }); + + // Add a command completer of we are using JLine + if (console instanceof JLineConsole) { + ConsoleReader jline = ((JLineConsole)console).getReader(); + + // + // TODO: Figure out why this does not work!!!! + // + jline.setCompletionHandler(new CandidateListCompletionHandler()); + + String[] commands = (String[])shell.getCommandManager().commandNames().toArray(new String[0]); + + SimpleCompletor c = new SimpleCompletor(commands); + jline.addCompletor(c); + } } } Modified: 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-core/src/main/java/org/apache/geronimo/gshell/Shell.java?rev=411702&r1=411701&r2=411702&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java Mon Jun 5 00:42:57 2006 @@ -91,6 +91,10 @@ return io; } + public CommandManager getCommandManager() { + return commandManager; + } + public int execute(final String commandLine) throws Exception { assert commandLine != null; Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java?rev=411702&r1=411701&r2=411702&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java Mon Jun 5 00:42:57 2006 @@ -110,7 +110,7 @@ boolean debug = log.isDebugEnabled(); String line; - while ((line = console.readLine(prompter.getPrompt())) != null) { + while ((line = console.readLine(doGetPrompt())) != null) { if (debug) { log.debug("Read line: " + line); @@ -130,7 +130,7 @@ log.debug(" " + idx); } - Executor.Result result = executor.execute(line); + Executor.Result result = doExecute(line); // Allow executor to request that the loop stop if (result == Executor.Result.STOP) { @@ -152,6 +152,14 @@ // Use-case is that Shell might want to disallow and print a "use exit command", // but Script interp wants this to exit and return control to Shell. // + } + + protected Executor.Result doExecute(final String line) throws Exception { + return executor.execute(line); + } + + protected String doGetPrompt() { + return prompter.getPrompt(); } //