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


Java LineReaderBuilder类代码示例

本文整理汇总了Java中org.jline.reader.LineReaderBuilder的典型用法代码示例。如果您正苦于以下问题:Java LineReaderBuilder类的具体用法?Java LineReaderBuilder怎么用?Java LineReaderBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LineReaderBuilder类属于org.jline.reader包,在下文中一共展示了LineReaderBuilder类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GraphflowCli

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
/**
 * Constructs a CLI client that connects to the Graphflow server at the provided {@code
 * host:port}.
 *
 * @param grpcHost The gRPC server hostname.
 * @param grpcPort The gRPC server port.
 */
GraphflowCli(String grpcHost, int grpcPort) throws IOException {
    super(grpcHost, grpcPort);
    Logger.getLogger("org.jline").setLevel(Level.OFF);
    File historyFile = new File(HISTORY_FLE);
    LineReaderBuilder lineReaderBuilder = LineReaderBuilder.builder().terminal(
        TerminalBuilder.builder().build());
    try {
        if (!historyFile.exists()) {
            historyFile.createNewFile();
        }
        if (historyFile.canWrite()) {
            isHistoryEnabled = true;
            lineReaderBuilder = lineReaderBuilder.variable(LineReader.HISTORY_FILE,
                historyFile).history(new DefaultHistory());
        }
    } catch (IOException e) {
        // Ignore
    }
    lineReader = lineReaderBuilder.build();
}
 
开发者ID:graphflow,项目名称:graphflow,代码行数:28,代码来源:GraphflowCli.java

示例2: open

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
@Override
public void open() {
    parser = createParser();

    try {
        terminal = (terminalBuilder != null ? terminalBuilder : TerminalBuilder.builder()).build();
    } catch (IOException e) {
        throw SpongeUtils.wrapException(e);
    }

    LineReaderBuilder lineReaderBuilder = LineReaderBuilder.builder().appName(VersionInfo.PRODUCT).terminal(terminal).parser(parser);

    if (completer != null) {
        lineReaderBuilder.completer(completer);
    }

    reader = lineReaderBuilder.build();
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:19,代码来源:JLineInteractiveModeConsole.java

示例3: lineReader

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
public static LineReader lineReader(File historyPath, Optional<SignalHandler> handler,
        Completer... completers) {
    // Protect the history file as may contain sensitive information
    FileUtils.setPermissionsToOwnerOnly(historyPath);

    // Create JLine LineReader
    History history = new DefaultHistory();
    LineReader reader = LineReaderBuilder.builder().terminal(terminal(handler)).history(history)
            .parser(new DefaultParser()).variable(LineReader.HISTORY_FILE, historyPath)
            .completer(new AggregateCompleter(completers)).highlighter(new DefaultHighlighter())
            .build();
    history.attach(reader);

    setOptions(reader);

    return reader;
}
 
开发者ID:atomist-attic,项目名称:rug-cli,代码行数:18,代码来源:ShellUtils.java

示例4: start

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
public void start() {
    final Terminal terminal = TerminalConsoleAppender.getTerminal();
    if (terminal != null) {
        final LineReader reader = LineReaderBuilder.builder()
                .appName(this.pluginContainer.getName())
                .terminal(terminal)
                .completer(new ConsoleCommandCompleter())
                .build();
        reader.unsetOpt(Option.INSERT_TAB);
        reader.setVariable(LineReader.HISTORY_FILE, this.consoleHistoryFile);

        TerminalConsoleAppender.setReader(reader);
    }

    active = true;

    final Thread thread = new Thread(this::readCommandTask, "console");
    thread.setDaemon(true);
    thread.start();

    this.scheduler.createAsyncExecutor(this.pluginContainer).scheduleAtFixedRate(
            this::saveHistory, 120, 120, TimeUnit.SECONDS);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:24,代码来源:ConsoleManager.java

示例5: lineReader

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
private static LineReader lineReader(Parser parser) {
    try {
        return LineReaderBuilder.builder().terminal(TerminalBuilder.terminal()).parser(parser).build();
    } catch (IOException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
 
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:8,代码来源:Neo4jRepl.java

示例6: Shell

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
public Shell() throws IOException {
    commandPrefix = ":";
    prompt = "> ";
    Terminal terminal = TerminalBuilder.builder()
        .build();
    reader = LineReaderBuilder.builder()
        .terminal(terminal)
        .build();
    logger.trace("create interpreter");
    interpreter = new NaiveInterpreter();
    // need to have a global ast builder, otherwise the symbol table is lost
    logger.trace("create ast builder");
    astBuilder = new ReikaAstBuilder(false);
}
 
开发者ID:xephonhq,项目名称:tsdb-proxy-java,代码行数:15,代码来源:Shell.java

示例7: processInputs

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
public void processInputs(InputStream is, OutputStream os, String terminalType) {
    try (Terminal terminal = TerminalBuilder.builder().system(false).type(terminalType).streams(is, os).build()) {
        LineReader reader = LineReaderBuilder.builder().terminal(terminal).completer(completer).build();
        createDefaultSessionContext(reader, terminal);
        ConsoleIO.writeOutput(SUPPORTED_COMMANDS_MESSAGE);
        processUserInput(reader);
    } catch (IOException ex) {
        log.error("Error building terminal instance", ex);
    }
}
 
开发者ID:anand1st,项目名称:sshd-shell-spring-boot,代码行数:11,代码来源:TerminalProcessor.java

示例8: newLineReader

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
/**
 * Creates a {@link LineReader} with the specified {@link Terminal}.
 *
 * @param terminal the terminal to use in the line reader
 * @return new line reader
 */
static LineReader newLineReader(Terminal terminal) {
    final LineReader reader = LineReaderBuilder.builder()
                                               .terminal(terminal)
                                               .build();
    return reader;
}
 
开发者ID:SpineEventEngine,项目名称:todo-list,代码行数:13,代码来源:Readers.java

示例9: JLineInPort

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
public JLineInPort(InputStream in, Path name, OutPort tie, Terminal terminal)
    throws java.io.IOException {
    super(in, name, tie);
    jlreader = LineReaderBuilder.builder()
        .terminal(terminal)
        .completer(this)
        .parser(this)
        .build();
    jlreader.setOpt(LineReader.Option.MOUSE);
    language = Language.getDefaultLanguage();
    this.terminal = terminal;
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:13,代码来源:JLineInPort.java

示例10: JLineReader

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
public JLineReader(Terminal terminal) {
  // The combination of parser/expander here allow for multiple-line commands connected by '\\'
  DefaultParser parser = new DefaultParser();
  parser.setEofOnEscapedNewLine(true);
  parser.setQuoteChars(new char[0]);
  parser.setEscapeChars(new char[] {'\\'});

  final Expander expander = new NoOpExpander();
  // TODO: specify a completer to use here via a call to LineReaderBuilder.completer()
  this.lineReader = LineReaderBuilder.builder()
      .appName("KSQL")
      .expander(expander)
      .parser(parser)
      .terminal(terminal)
      .build();

  this.lineReader.setOpt(LineReader.Option.HISTORY_IGNORE_DUPS);
  this.lineReader.setOpt(LineReader.Option.HISTORY_IGNORE_SPACE);

  Path historyFilePath = Paths.get(System.getProperty("history-file",  System.getProperty("user.home") + "/.ksql-history")).toAbsolutePath();
  if (CliUtils.createFile(historyFilePath)) {
    this.lineReader.setVariable(LineReader.HISTORY_FILE, historyFilePath);
    LOGGER.info("Command history saved at: " + historyFilePath);
  } else {
    terminal.writer().println(String.format("WARNING: Unable to create command history file '%s', command history will not be saved.", historyFilePath));
  }

  this.lineReader.unsetOpt(LineReader.Option.HISTORY_INCREMENTAL);
  this.history = new DefaultHistory(this.lineReader);

  this.prompt = DEFAULT_PROMPT;
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:33,代码来源:JLineReader.java

示例11: InternalJlineManager

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
private InternalJlineManager() throws Exception
{
    Logger.getLogger( "org.jline" ).setLevel( Level.ALL );
    terminal = TerminalBuilder.builder().dumb( true ).build();
    lineReader = LineReaderBuilder.builder()
            .terminal( terminal ).appName( "Kvantum" ).build();
}
 
开发者ID:Sauilitired,项目名称:Kvantum,代码行数:8,代码来源:InternalJlineManager.java

示例12: provideLineReader

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
@Provides
@Singleton
static LineReader provideLineReader(Terminal terminal) {
  return LineReaderBuilder.builder().terminal(terminal).appName("TCT").build();
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:6,代码来源:TerminalModule.java

示例13: JLineConsole

import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
public JLineConsole() throws IOException {
    this.terminal = TerminalBuilder.builder().encoding(encoding).build();
    this.reader = LineReaderBuilder.builder().appName(APP_NAME).terminal(terminal).build();
    this.commandReader = LineReaderBuilder.builder().appName(APP_NAME).terminal(terminal).build();
}
 
开发者ID:aspectran,项目名称:aspectran,代码行数:6,代码来源:JLineConsole.java


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