Search in sources :

Example 1 with ContextAwareQuitHandler

use of org.infinispan.cli.impl.ContextAwareQuitHandler in project infinispan by infinispan.

the class CLI method interactive.

private CommandResult interactive(Shell shell) {
    // We now start an interactive CLI
    CommandRegistry commandRegistry = initializeCommands();
    context.setRegistry(commandRegistry);
    CliAliasManager aliasManager;
    try {
        aliasManager = new CliAliasManager(context.getConfigPath().resolve("aliases").toFile(), true, commandRegistry);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    SettingsBuilder settings = SettingsBuilder.builder();
    settings.enableAlias(true).aliasManager(aliasManager).historyFile(context.getConfigPath().resolve("history").toFile()).outputStream(System.out).outputStreamError(System.err).inputStream(System.in).commandActivatorProvider(new ContextAwareCommandActivatorProvider(context)).commandInvocationProvider(new ContextAwareCommandInvocationProvider(context)).commandNotFoundHandler(new CliCommandNotFoundHandler()).completerInvocationProvider(new ContextAwareCompleterInvocationProvider(context)).commandRegistry(commandRegistry).aeshContext(context).quitHandler(new ContextAwareQuitHandler(context));
    if (shell instanceof AeshDelegatingShell) {
        settings.connection(((AeshDelegatingShell) shell).getConnection());
    }
    ReadlineConsole console = new ReadlineConsole(settings.build());
    context.setConsole(console);
    try {
        console.start();
        return CommandResult.SUCCESS;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : SettingsBuilder(org.aesh.command.settings.SettingsBuilder) CommandRegistry(org.aesh.command.registry.CommandRegistry) CliAliasManager(org.infinispan.cli.impl.CliAliasManager) AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) ReadlineConsole(org.aesh.readline.ReadlineConsole) ContextAwareQuitHandler(org.infinispan.cli.impl.ContextAwareQuitHandler) IOException(java.io.IOException) CliCommandNotFoundHandler(org.infinispan.cli.impl.CliCommandNotFoundHandler) ContextAwareCompleterInvocationProvider(org.infinispan.cli.completers.ContextAwareCompleterInvocationProvider) ContextAwareCommandActivatorProvider(org.infinispan.cli.activators.ContextAwareCommandActivatorProvider) ContextAwareCommandInvocationProvider(org.infinispan.cli.impl.ContextAwareCommandInvocationProvider)

Aggregations

IOException (java.io.IOException)1 CommandRegistry (org.aesh.command.registry.CommandRegistry)1 SettingsBuilder (org.aesh.command.settings.SettingsBuilder)1 ReadlineConsole (org.aesh.readline.ReadlineConsole)1 ContextAwareCommandActivatorProvider (org.infinispan.cli.activators.ContextAwareCommandActivatorProvider)1 ContextAwareCompleterInvocationProvider (org.infinispan.cli.completers.ContextAwareCompleterInvocationProvider)1 AeshDelegatingShell (org.infinispan.cli.impl.AeshDelegatingShell)1 CliAliasManager (org.infinispan.cli.impl.CliAliasManager)1 CliCommandNotFoundHandler (org.infinispan.cli.impl.CliCommandNotFoundHandler)1 ContextAwareCommandInvocationProvider (org.infinispan.cli.impl.ContextAwareCommandInvocationProvider)1 ContextAwareQuitHandler (org.infinispan.cli.impl.ContextAwareQuitHandler)1