Search in sources :

Example 1 with ShellClient

use of org.neo4j.shell.ShellClient in project neo4j by neo4j.

the class JLineConsole method newConsoleOrNullIfNotFound.

static JLineConsole newConsoleOrNullIfNotFound(ShellClient client) {
    try {
        Object consoleReader = Class.forName("jline.console.ConsoleReader").newInstance();
        consoleReader.getClass().getMethod("setBellEnabled", Boolean.TYPE).invoke(consoleReader, false);
        consoleReader.getClass().getMethod("setExpandEvents", Boolean.TYPE).invoke(consoleReader, false);
        consoleReader.getClass().getMethod("setHistoryEnabled", Boolean.TYPE).invoke(consoleReader, true);
        Object completer = Class.forName(JLineConsole.class.getPackage().getName() + "." + "ShellTabCompleter").getConstructor(ShellClient.class).newInstance(client);
        Class<?> completerClass = Class.forName("jline.console.completer.Completer");
        consoleReader.getClass().getMethod("addCompleter", completerClass).invoke(consoleReader, completer);
        Class<?> historyClass = Class.forName("jline.console.history.History");
        Object history = Class.forName("jline.console.history.FileHistory").getConstructor(File.class).newInstance(new File(System.getProperty("user.home"), ".neo4j_shell_history"));
        consoleReader.getClass().getMethod("setHistory", historyClass).invoke(consoleReader, history);
        return new JLineConsole(consoleReader, client);
    } catch (RuntimeException e) {
        // for instance, throw instead.
        throw e;
    } catch (Exception e) {
        return null;
    }
}
Also used : ShellClient(org.neo4j.shell.ShellClient) File(java.io.File)

Example 2 with ShellClient

use of org.neo4j.shell.ShellClient in project neo4j by neo4j.

the class TestPullUpdates method callPullUpdatesViaShell.

private void callPullUpdatesViaShell(int i) throws ShellException {
    ShellClient client = ShellLobby.newClient(SHELL_PORT + i);
    client.evaluate("pullupdates");
}
Also used : ShellClient(org.neo4j.shell.ShellClient)

Aggregations

ShellClient (org.neo4j.shell.ShellClient)2 File (java.io.File)1