|
1 | 1 | package org.esmerilprogramming.scalaesh
|
2 | 2 |
|
3 |
| -import java.io.File |
4 |
| -import java.nio.file._ |
5 |
| - |
6 |
| -import org.jboss.aesh.cl._ |
7 | 3 | import org.jboss.aesh.console._
|
8 |
| -import org.jboss.aesh.console.command._ |
9 |
| -import org.jboss.aesh.console.command.invocation._ |
10 | 4 | import org.jboss.aesh.console.command.registry._
|
11 | 5 | import org.jboss.aesh.console.settings._
|
12 |
| -import org.jboss.aesh.extensions.harlem.aesh._ |
| 6 | +import org.jboss.aesh.extensions.harlem.aesh.Harlem |
13 | 7 | import org.jboss.aesh.extensions.pwd._
|
14 |
| -import java.io._ |
| 8 | +import org.jboss.aesh.extensions.mkdir._ |
| 9 | +import org.jboss.aesh.extensions.rm._ |
| 10 | +import org.jboss.aesh.extensions.echo._ |
| 11 | +import org.jboss.aesh.extensions.matrix._ |
| 12 | +import org.jboss.aesh.extensions.cat._ |
| 13 | +import org.jboss.aesh.extensions.touch._ |
| 14 | +import org.jboss.aesh.extensions.cd._ |
| 15 | +import org.jboss.aesh.extensions.ls._ |
| 16 | +import org.jboss.aesh.extensions.clear._ |
15 | 17 |
|
16 | 18 | import org.jboss.aesh.terminal.{Color, TerminalColor, TerminalString, TestTerminal}
|
17 | 19 |
|
18 | 20 |
|
19 | 21 | /**
|
20 | 22 | * simple aesh scala wrapper.
|
21 |
| - * author helio frota at gmail dot com. |
| 23 | + * @author <a href="mailto:00hf11@gmail.com">Helio Frota</a> |
22 | 24 | */
|
23 | 25 | object ScalaeshApp extends App {
|
24 | 26 |
|
25 |
| - val pos = new PipedOutputStream(); |
26 |
| - val pis = new PipedInputStream(pos); |
27 |
| - val baos = new ByteArrayOutputStream(); |
28 |
| - |
29 |
| - val sb = new SettingsBuilder() |
30 |
| - .terminal(new TestTerminal()) |
31 |
| - .inputStream(pis) |
32 |
| - .outputStream(new PrintStream(baos)) |
33 |
| - |
34 |
| - val registry = new AeshCommandRegistryBuilder() |
35 |
| - .command(new Harlem()) |
36 |
| - .command(new Pwd()) |
37 |
| - .create(); |
38 |
| - |
39 |
| - val aeshConsole = new AeshConsoleBuilder() |
40 |
| - .commandRegistry(registry) |
41 |
| - .settings(sb.create()) |
42 |
| - .prompt(new Prompt(new TerminalString("[scalaesh@metal]$ ", |
43 |
| - new TerminalColor(Color.GREEN, Color.DEFAULT, Color.Intensity.BRIGHT)))) |
44 |
| - .create(); |
45 |
| - |
46 |
| - aeshConsole.start(); |
| 27 | + val sb = new SettingsBuilder(); |
| 28 | + sb.readInputrc(false); |
| 29 | + sb.logging(true); |
| 30 | + |
| 31 | + val acr = new AeshCommandRegistryBuilder(); |
| 32 | + acr.command(new Pwd()); |
| 33 | + acr.command(new Clear()); |
| 34 | + acr.command(new Harlem()); |
| 35 | + acr.command(new Cat()); |
| 36 | + acr.command(new Touch()); |
| 37 | + acr.command(new Cd()); |
| 38 | + acr.command(new Ls()); |
| 39 | + acr.command(new Matrix()); |
| 40 | + acr.command(new Mkdir()); |
| 41 | + acr.command(new Echo()); |
| 42 | + acr.command(new Rm()); |
| 43 | + |
| 44 | + val acb = new AeshConsoleBuilder() |
| 45 | + acb.commandRegistry(acr.create()); |
| 46 | + acb.settings(sb.create()); |
| 47 | + acb.prompt(new Prompt("[scalaesh@localhost]$ ")); |
| 48 | + acb.create().start(); |
47 | 49 |
|
48 | 50 | }
|
0 commit comments