Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 77323 invoked from network); 18 Sep 2007 02:30:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Sep 2007 02:30:56 -0000 Received: (qmail 91078 invoked by uid 500); 18 Sep 2007 02:30:48 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 91028 invoked by uid 500); 18 Sep 2007 02:30:48 -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 91015 invoked by uid 99); 18 Sep 2007 02:30:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 19:30:48 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Sep 2007 02:32:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 01A571A9832; Mon, 17 Sep 2007 19:30:32 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r576667 - /geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java Date: Tue, 18 Sep 2007 02:30:32 -0000 To: scm@geronimo.apache.org From: jdillon@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070918023033.01A571A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jdillon Date: Mon Sep 17 19:30:32 2007 New Revision: 576667 URL: http://svn.apache.org/viewvc?rev=576667&view=rev Log: Hook up some preliminary console support on the client-side Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java?rev=576667&r1=576666&r2=576667&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java Mon Sep 17 19:30:32 2007 @@ -30,7 +30,12 @@ import org.apache.geronimo.gshell.command.CommandSupport; import org.apache.geronimo.gshell.command.annotation.CommandComponent; import org.apache.geronimo.gshell.clp.Argument; +import org.apache.geronimo.gshell.console.Console; +import org.apache.geronimo.gshell.console.JLineConsole; +import org.apache.geronimo.gshell.ExitNotification; +import org.apache.geronimo.gshell.ansi.Renderer; import org.codehaus.plexus.component.annotations.Requirement; +import jline.Terminal; /** * Command to connect to a remote shell server. @@ -45,6 +50,9 @@ private URI location; @Requirement + private Terminal terminal; + + @Requirement private RshClientFactory factory; private RshClient client; @@ -55,73 +63,45 @@ client = factory.connect(location); io.out.println("Connected"); - - client.echo("TESTING"); client.handshake(); - /* - client.echo("READ_STREAMS"); + Console.Executor executor = new Console.Executor() { + public Result execute(final String line) throws Exception { + assert line != null; - OutputStream out = client.getOutputStream(); - final PrintWriter writer = new PrintWriter(out); + client.echo(line); - InputStream in = client.getInputStream(); - final BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - - Thread t = new Thread("Stream Consumer") { - public void run() { - try { - log.debug("Consumer running..."); - - String line; - while ((line = reader.readLine()) != null) { - System.err.println(line); - } - - log.debug("Consumer stopped"); - } - catch (Exception e) { - log.error(e.getMessage(), e); - } + return Result.CONTINUE; } }; - t.start(); + JLineConsole console = new JLineConsole(executor, io, terminal); + + console.setPrompter(new Console.Prompter() { + Renderer renderer = new Renderer(); - Thread t2 = new Thread("Noise Maker") { - public void run() { - try { - log.debug("Noise Maker..."); - - while (true) { - writer.println("FROM CLIENT: " + new Date()); - writer.flush(); - - Thread.sleep(1000 * 5); - } - - // log.debug("Noise Maker stopped"); - } - catch (Exception e) { - log.error(e.getMessage(), e); - } + public String prompt() { + String userName = "user"; + String hostName = "remote"; + String path = "/"; + + return renderer.render("@|bold " + userName + "|@" + hostName + ":@|bold " + path + "|> "); } - }; + }); - t2.start(); + console.setErrorHandler(new Console.ErrorHandler() { + public Result handleError(final Throwable error) { + assert error != null; - t.join(); - t2.join(); - */ + log.error("Communication error: " + error, error); - boolean running = true; - - while (running) { - client.echo(new Date().toString()); - Thread.sleep(1000 * 5); - } + return Result.CONTINUE; + } + }); + console.run(); + client.close(); return SUCCESS;