本文整理汇总了Java中org.jboss.aesh.console.Console类的典型用法代码示例。如果您正苦于以下问题:Java Console类的具体用法?Java Console怎么用?Java Console使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Console类属于org.jboss.aesh.console包,在下文中一共展示了Console类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createConsole
import org.jboss.aesh.console.Console; //导入依赖的package包/类
/**
* Creates the REPL's console.
* @param commandLine The command line options.
*/
private Console createConsole(CommandLine commandLine) {
// console settings
boolean useAnsi = !commandLine.hasOption("na");
SettingsBuilder settings = new SettingsBuilder().enableAlias(true)
.enableMan(true)
.ansi(useAnsi)
.parseOperators(false)
.inputStream(PausableInput.INSTANCE);
if(commandLine.hasOption("irc")) {
settings = settings.inputrc(new File(commandLine.getOptionValue("irc")));
}
return new Console(settings.create());
}
示例2: run
import org.jboss.aesh.console.Console; //导入依赖的package包/类
public void run() throws IOException {
Console console = new Console();
ConsoleOutput line;
while ((line = console.read("aql> ")) != null) {
if (line.getBuffer().equalsIgnoreCase("quit") || line.getBuffer().equalsIgnoreCase("exit")) {
System.exit(0);
} else
query(line.getBuffer(), console);
}
}
示例3: createExecutor
import org.jboss.aesh.console.Console; //导入依赖的package包/类
/**
* Creates the Stellar execution environment.
* @param commandLine The command line arguments.
* @param console The console which drives the REPL.
* @param properties Stellar properties.
*/
private StellarShellExecutor createExecutor(
CommandLine commandLine,
Console console,
Properties properties,
StellarAutoCompleter autoCompleter) throws Exception {
// setup zookeeper client
Optional<String> zookeeperUrl = Optional.empty();
if(commandLine.hasOption("z")) {
zookeeperUrl = Optional.of(commandLine.getOptionValue("z"));
}
StellarShellExecutor executor = new DefaultStellarShellExecutor(properties, zookeeperUrl);
// the 'CONSOLE' capability is only available with the CLI REPL
executor.getContext().addCapability(CONSOLE, () -> console);
// allows some Stellar functions to access Stellar internals; should probably use %magics instead
executor.getContext().addCapability(SHELL_VARIABLES, () -> executor.getState());
// register the auto-completer to be notified when needed
executor.addSpecialListener( (special) -> autoCompleter.addCandidateFunction(special.getCommand()));
executor.addFunctionListener( (function) -> autoCompleter.addCandidateFunction(function.getName()));
executor.addVariableListener((name, val) -> autoCompleter.addCandidateVariable(name));
executor.init();
return executor;
}
示例4: run
import org.jboss.aesh.console.Console; //导入依赖的package包/类
private void run(List<InetSocketAddress> addresses) {
mapper = new ObjectMapper();
client = new StratumClient(params, addresses, true);
InputStream checkpointsInputStream = openResource(String.format("checkpoints-%s.txt", net));
CheckpointManager checkpoints;
try {
checkpoints = new CheckpointManager(params, checkpointsInputStream);
} catch (IOException e) {
throw propagate(e);
}
store = new HeadersStore(params, new File(net + "-stratum.chain"), checkpoints.getCheckpointBefore(new Date().getTime()), getResource(net + "-headers.gz"));
chain = new StratumChain(params, store, client);
client.startAsync();
chain.startAsync();
CommandRegistry registry = new AeshCommandRegistryBuilder()
.command(new ExitCommand())
.command(new CloseCommand())
.command(new ConnectCommand())
.command(new HeaderCommand())
.command(new HistoryCommand())
.command(new BalanceCommand())
.command(new GetTransactionCommand())
.command(new UnspentCommand())
.command(new VersionCommand())
.command(new BannerCommand())
.command(new HelpCommand())
.command(new SubscribeAddressCommand())
.command(new SubscribeHeadersCommand())
.command(new SetQueueCommand())
.command(new InfoCommand())
.command(new DumpChainCommand())
.create();
Settings settings = new SettingsBuilder()
.logging(false)
.persistHistory(true)
.historyFile(new File(System.getProperty("user.home"), ".cache/stratum-cli.hist"))
.interruptHook(new InterruptHook() {
@Override
public void handleInterrupt(Console console, Action action) {
if (action == Action.EOF) {
console.stop();
cleanup();
}
}
})
.create();
console = new AeshConsoleBuilder()
.commandRegistry(registry)
.settings(settings)
.prompt(new Prompt(new TerminalString("[[email protected]]$ ",
new TerminalColor(Color.GREEN, Color.DEFAULT, Color.Intensity.BRIGHT))))
.create();
console.start();
}
示例5: getConsole
import org.jboss.aesh.console.Console; //导入依赖的package包/类
/**
* @return The console.
*/
public Console getConsole() {
return console;
}