use of org.aesh.readline.ReadlineConsole in project galleon by wildfly.
the class CliMain method startInteractive.
private static void startInteractive(PmSession pmSession, CliTerminalConnection connection, boolean paging) throws Throwable {
pmSession.setOut(connection.getOutput());
pmSession.setErr(connection.getOutput());
// Side effect is to resolve plugins.
pmSession.getUniverse().resolveBuiltinUniverse();
Settings<? extends CommandInvocation, ? extends ConverterInvocation, ? extends CompleterInvocation, ? extends ValidatorInvocation, ? extends OptionActivator, ? extends CommandActivator> settings = buildSettings(pmSession, connection, new InteractiveInvocationProvider(pmSession, paging));
ReadlineConsole console = new ReadlineConsole(settings);
pmSession.setAeshContext(console.context());
console.setPrompt(pmSession.buildPrompt());
// connection is automatically closed when exit command or Ctrl-D
console.start();
}
use of org.aesh.readline.ReadlineConsole in project quarkus by quarkusio.
the class AeshConsole method runAeshCli.
public void runAeshCli() {
if (ConsoleCliManager.commands.isEmpty()) {
System.out.println("No commands registered, please wait for Quarkus to start before using the console");
return;
}
try {
pauseOutput = true;
delegateConnection = new DelegateConnection(connection);
connection.write(ALTERNATE_SCREEN_BUFFER);
if (firstConsoleRun) {
connection.write("You are now in Quarkus Terminal. Your app is still running. Use `help` or tab completion to explore, `quit` or `q` to return to your application.\n");
firstConsoleRun = false;
}
AeshCommandRegistryBuilder<CommandInvocation> commandBuilder = AeshCommandRegistryBuilder.builder();
ConsoleCliManager.commands.forEach(commandBuilder::command);
CommandRegistry registry = commandBuilder.create();
Settings settings = SettingsBuilder.builder().enableExport(false).enableAlias(true).aliasManager(new AliasManager(Paths.get(System.getProperty("user.home")).resolve(ALIAS_FILE).toFile(), true)).connection(delegateConnection).commandRegistry(registry).build();
aeshConsole = new ReadlineConsole(settings);
aeshConsole.setPrompt("quarkus$ ");
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
aeshConsole.start();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}, "Quarkus integrated CLI thread");
t.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.aesh.readline.ReadlineConsole 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);
}
}
Aggregations