Search in sources :

Example 1 with App

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

the class Man method execute.

@Override
public Continuation execute(AppCommandParser parser, Session session, Output out) throws Exception {
    if (parser.arguments().size() == 0) {
        boolean list = parser.options().containsKey("l");
        printHelpString(out, getServer(), list);
        return Continuation.INPUT_COMPLETE;
    }
    App app = this.getApp(parser);
    out.println("");
    for (String line : splitLongLine(fixDesciption(app.getDescription()), CONSOLE_WIDTH)) {
        out.println(line);
    }
    println(out, "");
    boolean hasOptions = false;
    for (String option : app.getAvailableOptions()) {
        hasOptions = true;
        String description = fixDesciption(app.getDescription(option));
        String[] descriptionLines = splitLongLine(description, CONSOLE_WIDTH);
        for (int i = 0; i < descriptionLines.length; i++) {
            String line = "";
            if (i == 0) {
                String optionPrefix = option.length() > 1 ? "--" : "-";
                line = optionPrefix + option;
            }
            line += "\t ";
            line += descriptionLines[i];
            println(out, line);
        }
    }
    if (hasOptions) {
        println(out, "");
    }
    return Continuation.INPUT_COMPLETE;
}
Also used : App(org.neo4j.shell.App) AbstractApp(org.neo4j.shell.impl.AbstractApp)

Example 2 with App

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

the class AbstractAppServer method tabComplete.

@Override
public TabCompletion tabComplete(Serializable clientID, String partOfLine) throws ShellException, RemoteException {
    // TODO We can't assume it's an AppShellServer, can we?
    try {
        AppCommandParser parser = new AppCommandParser(this, partOfLine);
        App app = parser.app();
        List<String> appCandidates = app.completionCandidates(partOfLine, getClientSession(clientID));
        appCandidates = quote(appCandidates);
        if (appCandidates.size() == 1) {
            appCandidates.set(0, appCandidates.get(0) + " ");
        }
        int cursor = partOfLine.length() - TextUtil.lastWordOrQuoteOf(partOfLine, true).length();
        return new TabCompletion(appCandidates, cursor);
    } catch (Exception e) {
        throw wrapException(e);
    }
}
Also used : App(org.neo4j.shell.App) TabCompletion(org.neo4j.shell.TabCompletion) AppCommandParser(org.neo4j.shell.AppCommandParser) RemoteException(java.rmi.RemoteException) ShellException(org.neo4j.shell.ShellException)

Example 3 with App

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

the class Man method getApp.

private App getApp(AppCommandParser parser) throws Exception {
    String appName = parser.arguments().get(0).toLowerCase();
    App app = this.getServer().findApp(appName);
    if (app == null) {
        throw new ShellException("No manual entry for '" + appName + "'");
    }
    return app;
}
Also used : App(org.neo4j.shell.App) AbstractApp(org.neo4j.shell.impl.AbstractApp) ShellException(org.neo4j.shell.ShellException)

Aggregations

App (org.neo4j.shell.App)3 ShellException (org.neo4j.shell.ShellException)2 AbstractApp (org.neo4j.shell.impl.AbstractApp)2 RemoteException (java.rmi.RemoteException)1 AppCommandParser (org.neo4j.shell.AppCommandParser)1 TabCompletion (org.neo4j.shell.TabCompletion)1