use of org.infinispan.cli.impl.CliCommandNotFoundHandler in project infinispan by infinispan.
the class CLI method batch.
private CommandResult batch(String inputFile, Shell shell) {
CommandRegistry commandRegistry = initializeCommands(Batch.class);
AeshCommandRuntimeBuilder runtimeBuilder = AeshCommandRuntimeBuilder.builder();
runtimeBuilder.commandActivatorProvider(new ContextAwareCommandActivatorProvider(context)).commandInvocationProvider(new ContextAwareCommandInvocationProvider(context)).commandNotFoundHandler(new CliCommandNotFoundHandler()).completerInvocationProvider(new ContextAwareCompleterInvocationProvider(context)).aeshContext(context).commandRegistry(commandRegistry);
runtimeBuilder.shell(shell);
CliRuntimeRunner cliRunner = new CliRuntimeRunner("batch", runtimeBuilder.build());
int exitCode = cliRunner.args(new String[] { "run", inputFile }).execute();
context.disconnect();
return CommandResult.valueOf(exitCode);
}
use of org.infinispan.cli.impl.CliCommandNotFoundHandler 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);
}
}
use of org.infinispan.cli.impl.CliCommandNotFoundHandler in project infinispan by infinispan.
the class CLI method initialCommandRuntimeBuilder.
private static AeshCommandRuntimeBuilder initialCommandRuntimeBuilder(Shell shell, Properties properties, boolean kube) throws CommandRegistryException {
AeshCommandRegistryBuilder registryBuilder = AeshCommandRegistryBuilder.builder();
Context context;
if (kube) {
context = new KubernetesContext(properties);
registryBuilder.command(Kube.class);
} else {
context = new ContextImpl(properties);
registryBuilder.command(CLI.class);
}
AeshCommandRuntimeBuilder runtimeBuilder = AeshCommandRuntimeBuilder.builder();
runtimeBuilder.commandActivatorProvider(new ContextAwareCommandActivatorProvider(context)).commandInvocationProvider(new ContextAwareCommandInvocationProvider(context)).commandNotFoundHandler(new CliCommandNotFoundHandler()).completerInvocationProvider(new ContextAwareCompleterInvocationProvider(context)).shell(shell).aeshContext(context).commandRegistry(registryBuilder.create());
return runtimeBuilder;
}
Aggregations