本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例12: provideLineReader
import org.jline.reader.LineReaderBuilder; //导入依赖的package包/类
@Provides
@Singleton
static LineReader provideLineReader(Terminal terminal) {
return LineReaderBuilder.builder().terminal(terminal).appName("TCT").build();
}
示例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();
}