Search in sources :

Example 1 with CliRuntimeRunner

use of org.infinispan.cli.impl.CliRuntimeRunner 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);
}
Also used : CommandRegistry(org.aesh.command.registry.CommandRegistry) AeshCommandRuntimeBuilder(org.aesh.command.AeshCommandRuntimeBuilder) CliCommandNotFoundHandler(org.infinispan.cli.impl.CliCommandNotFoundHandler) ContextAwareCompleterInvocationProvider(org.infinispan.cli.completers.ContextAwareCompleterInvocationProvider) CliRuntimeRunner(org.infinispan.cli.impl.CliRuntimeRunner) ContextAwareCommandActivatorProvider(org.infinispan.cli.activators.ContextAwareCommandActivatorProvider) ContextAwareCommandInvocationProvider(org.infinispan.cli.impl.ContextAwareCommandInvocationProvider)

Example 2 with CliRuntimeRunner

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

the class CLI method main.

public static int main(Shell shell, String[] args, Properties properties, boolean kube) {
    CommandRuntime runtime = null;
    try {
        SecurityActions.addSecurityProvider(WildFlyElytronCredentialStoreProvider.getInstance());
        runtime = initialCommandRuntimeBuilder(shell, properties, kube).build();
        int exitCode = new CliRuntimeRunner(kube ? "kube" : "cli", runtime).args(args).execute();
        return exitCode;
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        if (runtime != null) {
            Util.close((AutoCloseable) runtime.getAeshContext());
        }
    }
}
Also used : CommandRuntime(org.aesh.command.CommandRuntime) CliRuntimeRunner(org.infinispan.cli.impl.CliRuntimeRunner) CommandRegistryException(org.aesh.command.registry.CommandRegistryException) IOException(java.io.IOException)

Aggregations

CliRuntimeRunner (org.infinispan.cli.impl.CliRuntimeRunner)2 IOException (java.io.IOException)1 AeshCommandRuntimeBuilder (org.aesh.command.AeshCommandRuntimeBuilder)1 CommandRuntime (org.aesh.command.CommandRuntime)1 CommandRegistry (org.aesh.command.registry.CommandRegistry)1 CommandRegistryException (org.aesh.command.registry.CommandRegistryException)1 ContextAwareCommandActivatorProvider (org.infinispan.cli.activators.ContextAwareCommandActivatorProvider)1 ContextAwareCompleterInvocationProvider (org.infinispan.cli.completers.ContextAwareCompleterInvocationProvider)1 CliCommandNotFoundHandler (org.infinispan.cli.impl.CliCommandNotFoundHandler)1 ContextAwareCommandInvocationProvider (org.infinispan.cli.impl.ContextAwareCommandInvocationProvider)1