use of org.neo4j.shell.AppCommandParser 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.AppCommandParser in project neo4j by neo4j.
the class Dump method newParser.
private AppCommandParser newParser(AppCommandParser parser) throws ShellException {
String newLine = parser.getLineWithoutApp();
AppCommandParser newParser = newParser(newLine);
newParser.options().putAll(parser.options());
return newParser;
}
use of org.neo4j.shell.AppCommandParser in project neo4j by neo4j.
the class CdTest method shouldProvideTabCompletions.
@Test
public void shouldProvideTabCompletions() throws Exception {
// GIVEN
Node root = createNodeWithSomeSubNodes("Mattias", "Magnus", "Tobias");
Cd app = (Cd) server.findApp("cd");
app.execute(new AppCommandParser(server, "cd -a " + root.getId()), session, silence);
// WHEN
List<String> candidates = app.completionCandidates("cd Ma", session);
// THEN
assertHasCandidate(candidates, "Mattias");
assertHasCandidate(candidates, "Magnus");
}
use of org.neo4j.shell.AppCommandParser in project neo4j by neo4j.
the class AbstractAppServer method interpretLine.
@Override
public Response interpretLine(Serializable clientId, String line, Output out) throws ShellException {
Session session = getClientSession(clientId);
if (line == null || line.trim().length() == 0) {
return new Response(getPrompt(session), Continuation.INPUT_COMPLETE);
}
try {
Continuation commandResult = null;
for (String command : line.split(Pattern.quote("&&"))) {
command = TextUtil.removeSpaces(command);
command = replaceAlias(command, session);
AppCommandParser parser = new AppCommandParser(this, command);
commandResult = parser.app().execute(parser, session, out);
}
return new Response(getPrompt(session), commandResult);
} catch (Exception e) {
throw wrapException(e);
}
}
use of org.neo4j.shell.AppCommandParser in project neo4j by neo4j.
the class Dump method execute.
@Override
public Continuation execute(AppCommandParser parser, Session session, Output out) throws Exception {
if (// Dump the whole graph
parser.arguments().isEmpty()) {
try (Transaction tx = getServer().getDb().beginTransaction(implicit, AUTH_DISABLED)) {
getServer().registerTopLevelTransactionInProgress(session.getId());
final SubGraph graph = DatabaseSubGraph.from(getServer().getDb());
export(graph, out);
tx.success();
return Continuation.INPUT_COMPLETE;
}
} else {
AppCommandParser newParser = newParser(parser);
return super.execute(newParser, session, out);
}
}
Aggregations