Search in sources :

Example 1 with Command

use of org.neo4j.shell.commands.Command in project neo4j by neo4j.

the class CommandHelperTest method shouldIgnoreCaseForCommands.

@Test
public void shouldIgnoreCaseForCommands() {
    // Given
    AnsiLogger logger = new AnsiLogger(false);
    CommandHelper commandHelper = new CommandHelper(logger, Historian.empty, new CypherShell(logger, PrettyConfig.DEFAULT, false, new ShellParameterMap()));
    // When
    Command begin = commandHelper.getCommand(":BEGIN");
    // Then
    assertTrue(begin instanceof Begin);
}
Also used : ShellParameterMap(org.neo4j.shell.ShellParameterMap) Command(org.neo4j.shell.commands.Command) Begin(org.neo4j.shell.commands.Begin) CypherShell(org.neo4j.shell.CypherShell) AnsiLogger(org.neo4j.shell.log.AnsiLogger) CommandHelper(org.neo4j.shell.commands.CommandHelper) Test(org.junit.Test)

Example 2 with Command

use of org.neo4j.shell.commands.Command in project neo4j by neo4j.

the class CypherShell method getCommandExecutable.

@Nonnull
protected Optional<CommandExecutable> getCommandExecutable(@Nonnull final String line) {
    Matcher m = cmdNamePattern.matcher(line);
    if (commandHelper == null || !m.matches()) {
        return Optional.empty();
    }
    String name = m.group("name");
    String args = m.group("args");
    Command cmd = commandHelper.getCommand(name);
    if (cmd == null) {
        return Optional.empty();
    }
    return Optional.of(() -> cmd.execute(stripTrailingSemicolons(args)));
}
Also used : Matcher(java.util.regex.Matcher) Command(org.neo4j.shell.commands.Command) Nonnull(javax.annotation.Nonnull)

Aggregations

Command (org.neo4j.shell.commands.Command)2 Matcher (java.util.regex.Matcher)1 Nonnull (javax.annotation.Nonnull)1 Test (org.junit.Test)1 CypherShell (org.neo4j.shell.CypherShell)1 ShellParameterMap (org.neo4j.shell.ShellParameterMap)1 Begin (org.neo4j.shell.commands.Begin)1 CommandHelper (org.neo4j.shell.commands.CommandHelper)1 AnsiLogger (org.neo4j.shell.log.AnsiLogger)1