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;
}
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);
}
}
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;
}
Aggregations