当前位置: 首页>>代码示例>>Java>>正文


Java Console类代码示例

本文整理汇总了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());
}
 
开发者ID:apache,项目名称:metron,代码行数:21,代码来源:StellarShell.java

示例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);
  }
}
 
开发者ID:ibm-security-intelligence,项目名称:jdbc-driver,代码行数:11,代码来源:Shell.java

示例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;
}
 
开发者ID:apache,项目名称:metron,代码行数:35,代码来源:StellarShell.java

示例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();
}
 
开发者ID:devrandom,项目名称:java-stratum,代码行数:56,代码来源:StratumCli.java

示例5: getConsole

import org.jboss.aesh.console.Console; //导入依赖的package包/类
/**
 * @return The console.
 */
public Console getConsole() {
  return console;
}
 
开发者ID:apache,项目名称:metron,代码行数:7,代码来源:StellarShell.java


注:本文中的org.jboss.aesh.console.Console类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。