本文整理汇总了Java中jline.console.completer.FileNameCompleter类的典型用法代码示例。如果您正苦于以下问题:Java FileNameCompleter类的具体用法?Java FileNameCompleter怎么用?Java FileNameCompleter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileNameCompleter类属于jline.console.completer包,在下文中一共展示了FileNameCompleter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConsole
import jline.console.completer.FileNameCompleter; //导入依赖的package包/类
public ConsoleReader getConsole() throws IOException {
if (console == null) {
// console = new ConsoleReader(System.in, System.out);
console = new ConsoleReader();
}
String osName = builtIn.getLocalOsName();
if (osName.toLowerCase().contains("win")) {
System.out.println("-----your Console is terrible.-----\n"
+ "if it reports some errors, just ignore it.");
console.setPrompt("[email protected]" + builtIn.getHostname() + "> ");
} else {
console.setPrompt("\u001B[33mjweevely\u001B[[email protected]"
+ builtIn.getHostname() + "\u001B[33m>\u001B[0m ");
}
List<Completer> completors = new ArrayList<Completer>();
completors.add(new StringsCompleter(BuiltIn.BUILTIN_FUNCTION));
completors.add(new FileNameCompleter());
completors.add(new NullCompleter());
console.addCompleter(new ArgumentCompleter(completors));
return console;
}
示例2: CommandCompleter
import jline.console.completer.FileNameCompleter; //导入依赖的package包/类
public CommandCompleter(ConsoleReader consoleReader,
ArgumentDelimiter argumentDelimiter, Iterable<Command> commands) {
this.console = consoleReader;
List<String> names = new ArrayList<String>();
for (Command command : commands) {
this.commands.add(command);
names.add(command.getName());
List<String> options = new ArrayList<String>();
for (OptionHelp optionHelp : command.getOptionsHelp()) {
options.addAll(optionHelp.getOptions());
}
AggregateCompleter argumentCompleters = new AggregateCompleter(
new StringsCompleter(options), new FileNameCompleter());
ArgumentCompleter argumentCompleter = new ArgumentCompleter(argumentDelimiter,
argumentCompleters);
argumentCompleter.setStrict(false);
this.commandCompleters.put(command.getName(), argumentCompleter);
}
getStrings().addAll(names);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:21,代码来源:CommandCompleter.java
示例3: CommandCompleter
import jline.console.completer.FileNameCompleter; //导入依赖的package包/类
public CommandCompleter(ConsoleReader consoleReader,
ArgumentDelimiter argumentDelimiter, Iterable<Command> commands) {
this.console = consoleReader;
List<String> names = new ArrayList<String>();
for (Command command : commands) {
this.commands.add(command);
names.add(command.getName());
List<String> options = new ArrayList<String>();
for (OptionHelp optionHelp : command.getOptionsHelp()) {
options.addAll(optionHelp.getOptions());
}
AggregateCompleter arguementCompleters = new AggregateCompleter(
new StringsCompleter(options), new FileNameCompleter());
ArgumentCompleter argumentCompleter = new ArgumentCompleter(argumentDelimiter,
arguementCompleters);
argumentCompleter.setStrict(false);
this.commandCompleters.put(command.getName(), argumentCompleter);
}
getStrings().addAll(names);
}
示例4: init
import jline.console.completer.FileNameCompleter; //导入依赖的package包/类
public void init() {
System.setProperty("library.jansi.version", "JaPS");
AnsiConsole.systemInstall();
try {
consoleReader = new ConsoleReader();
consoleReader.setExpandEvents(false);
} catch (IOException e) {
e.printStackTrace();
}
// Setup logging system
logger = new JaPSLogger(consoleReader);
System.setErr(new PrintStream(new LoggingOutputStream(logger, Level.SEVERE), true));
System.setOut(new PrintStream(new LoggingOutputStream(logger, Level.INFO), true));
// Register command
commandManager = new CommandManager();
commandManager.addCommand(new HelpCommand("help", new String[]{"h"}, "Show this output"));
commandManager.addCommand(new SubCommand("sub", new String[]{"s", "subscribe"}, "Subscribe a channel and view it's prepareCacheSync passing"));
commandManager.addCommand(new UnsubCommand("unsub", new String[]{}, "Unsubscribe previous subscribed channels"));
commandManager.addCommand(new EndCommand("end", new String[]{"stop"}, "Shutdown the server"));
commandManager.addCommand(new SetCommand("set", new String[]{"add"}, "Sets a key and value"));
commandManager.addCommand(new GetCommand("get", new String[]{}, "Gets a value from a key"));
commandManager.addCommand(new DeleteCommand("delete", new String[]{"remove", "del", "rm"}, "Gets a value from a key"));
commandManager.addCommand(new SnapshotCommand("snapshot", new String[]{}, "Takes a memory snapshot"));
// Autocomplete commands
consoleReader.addCompleter(new StringsCompleter(commandManager.getCommands().stream().map(Command::getName).collect(Collectors.toList())));
// Autocomplete files
consoleReader.addCompleter(new FileNameCompleter());
logger.info("Initialized");
}
示例5: setCommands
import jline.console.completer.FileNameCompleter; //导入依赖的package包/类
public void setCommands(CommandSet.Entry[] entries) throws IOException {
AggregateCompleter aggregateCompleter = new AggregateCompleter(new SimpleCompletor(getCommandsAsArray(entries)),
new ClassNameCompletor(),
new FileNameCompleter());
ArgumentCompleter argumentCompleter = new ArgumentCompleter(createArgumentDelimiter(), aggregateCompleter);
argumentCompleter.setStrict(false);
reader.addCompleter(argumentCompleter);
}
示例6: shouldSetCompleters
import jline.console.completer.FileNameCompleter; //导入依赖的package包/类
@Test
public void shouldSetCompleters() {
Completer completer = new FileNameCompleter();
underTest.setCompleters(ImmutableList.<Completer>builder().add(completer).build());
verify(consoleReader).addCompleter(completerCaptor.capture());
assertThat(completerCaptor.getValue(), is(completer));
}
示例7: selectCompleters
import jline.console.completer.FileNameCompleter; //导入依赖的package包/类
private List<Completer> selectCompleters() {
final List<Completer> selection = new ArrayList<Completer>();
for (Command eachCommand: configuration.getCommands()) {
selection.add(new StringsCompleter(eachCommand.getSyntax()));
}
selection.add(new FileNameCompleter());
return selection;
}
示例8: initAutoCompletion
import jline.console.completer.FileNameCompleter; //导入依赖的package包/类
void initAutoCompletion() {
LinkedList<Completer> completors = new LinkedList<Completer>();
completors.add(new StringsCompleter(cmdMap.keySet()));
completors.add(new StringsCompleter(fieldNames()));
completors.add(new FileNameCompleter());
consoleReader.addCompleter(new ArgumentCompleter(completors));
}
示例9: Init
import jline.console.completer.FileNameCompleter; //导入依赖的package包/类
private void Init(String accnt, String key, String cont) throws IOException
{
conReader = new ConsoleReader();
conReader.setPrompt("AzureShell> ");
List<Completer> completors = new LinkedList<>();
String currFileNameStr = "dir1";
AzFileProvider azfp = new AzFileProvider();
StaticUserAuthenticator auth = new StaticUserAuthenticator("", accnt, key);
AzFileSystemConfigBuilder.getInstance().setUserAuthenticator(azfp.getDefaultFileSystemOptions(), auth);
DefaultFileSystemManager currMan = new DefaultFileSystemManager();
currMan.addProvider(AzConstants.AZSBSCHEME, azfp);
currMan.addProvider("file", new DefaultLocalFileProvider());
currMan.init();
mgr = currMan;
//cwd = mgr.resolveFile(System.getProperty("user.dir"));c
String currAzURL = String.format("%s://%s/%s/%s",
AzConstants.AZSBSCHEME, accnt, cont, currFileNameStr);
cwd = mgr.resolveFile(currAzURL);
completors.add(new FileNameCompleter());
completors.add(new StringsCompleter(AzConstants.AZSBSCHEME, "file://", currAzURL));
AggregateCompleter aggComp = new AggregateCompleter(completors);
ArgumentCompleter argComp = new ArgumentCompleter(aggComp);
argComp.setStrict(false);
conReader.addCompleter(argComp);
Path histPath = Paths.get(System.getProperty("user.home"), ".simpleshellhist");
File histFile = histPath.toFile();
FileHistory fh = new FileHistory(histFile);
conReader.setHistory(fh);
conReader.setHistoryEnabled(true);
Runtime.getRuntime().addShutdownHook(
new Thread()
{
@Override
public void run()
{
try
{
((FileHistory)conReader.getHistory()).flush();
}
catch (IOException ex)
{
log.error("Error saving history", ex);
}
}
});
}
示例10: main
import jline.console.completer.FileNameCompleter; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
try {
Character mask = null;
String trigger = null;
boolean color = false;
ConsoleReader reader = new ConsoleReader();
reader.setPrompt("prompt> ");
if ((args == null) || (args.length == 0)) {
usage();
return;
}
List<Completer> completors = new LinkedList<Completer>();
if (args.length > 0) {
if (args[0].equals("none")) {
} else if (args[0].equals("files")) {
completors.add(new FileNameCompleter());
} else if (args[0].equals("simple")) {
completors.add(new StringsCompleter("foo", "bar", "baz"));
} else if (args[0].equals("color")) {
color = true;
reader.setPrompt("\u001B[1mfoo\u001B[[email protected]\u001B[[email protected]\u001B[0m> ");
} else {
usage();
return;
}
}
if (args.length == 3) {
mask = args[2].charAt(0);
trigger = args[1];
}
for (Completer c : completors) {
reader.addCompleter(c);
}
String line;
PrintWriter out = new PrintWriter(reader.getOutput());
while ((line = reader.readLine()) != null) {
if (color) {
out.println("\u001B[33m======>\u001B[0m\"" + line + "\"");
} else {
out.println("======>\"" + line + "\"");
}
out.flush();
// If we input the special word then we will mask
// the next line.
if ((trigger != null) && (line.compareTo(trigger) == 0)) {
line = reader.readLine("password> ", mask);
}
if (line.equalsIgnoreCase("quit")
|| line.equalsIgnoreCase("exit")) {
break;
}
if (line.equalsIgnoreCase("cls")) {
reader.clearScreen();
}
}
} catch (Throwable t) {
t.printStackTrace();
}
}
示例11: shouldAddCompleter
import jline.console.completer.FileNameCompleter; //导入依赖的package包/类
@Test
public void shouldAddCompleter() {
Completer completer = new FileNameCompleter();
AskBuilder.ask("Question").completeWith(completer).answer();
verify(consoleReader).addCompleter(completer);
}
示例12: SqlLine
import jline.console.completer.FileNameCompleter; //导入依赖的package包/类
public SqlLine() {
final TableNameCompleter tableCompleter = new TableNameCompleter(this);
final List<Completer> empty = Collections.emptyList();
commandHandlers = Arrays.<CommandHandler>asList(
new ReflectiveCommandHandler(this, empty, "quit", "done", "exit"),
new ReflectiveCommandHandler(this,
new StringsCompleter(getConnectionURLExamples()),
"connect", "open"),
new ReflectiveCommandHandler(this, empty, "nickname"),
new ReflectiveCommandHandler(this, tableCompleter, "describe"),
new ReflectiveCommandHandler(this, tableCompleter, "indexes"),
new ReflectiveCommandHandler(this, tableCompleter, "primarykeys"),
new ReflectiveCommandHandler(this, tableCompleter, "exportedkeys"),
new ReflectiveCommandHandler(this, empty, "manual"),
new ReflectiveCommandHandler(this, tableCompleter, "importedkeys"),
new ReflectiveCommandHandler(this, empty, "procedures"),
new ReflectiveCommandHandler(this, empty, "tables"),
new ReflectiveCommandHandler(this, empty, "typeinfo"),
new ReflectiveCommandHandler(this, tableCompleter, "columns"),
new ReflectiveCommandHandler(this, empty, "reconnect"),
new ReflectiveCommandHandler(this, tableCompleter, "dropall"),
new ReflectiveCommandHandler(this, empty, "history"),
new ReflectiveCommandHandler(this,
new StringsCompleter(getMetadataMethodNames()), "metadata"),
new ReflectiveCommandHandler(this, empty, "nativesql"),
new ReflectiveCommandHandler(this, empty, "dbinfo"),
new ReflectiveCommandHandler(this, empty, "rehash"),
new ReflectiveCommandHandler(this, empty, "verbose"),
new ReflectiveCommandHandler(this, new FileNameCompleter(), "run"),
new ReflectiveCommandHandler(this, empty, "batch"),
new ReflectiveCommandHandler(this, empty, "list"),
new ReflectiveCommandHandler(this, empty, "all"),
new ReflectiveCommandHandler(this, empty, "go", "#"),
new ReflectiveCommandHandler(this, new FileNameCompleter(), "script"),
new ReflectiveCommandHandler(this, new FileNameCompleter(), "record"),
new ReflectiveCommandHandler(this, empty, "brief"),
new ReflectiveCommandHandler(this, empty, "close"),
new ReflectiveCommandHandler(this, empty, "closeall"),
new ReflectiveCommandHandler(this,
new StringsCompleter(getIsolationLevels()), "isolation"),
new ReflectiveCommandHandler(this,
new StringsCompleter(formats.keySet()), "outputformat"),
new ReflectiveCommandHandler(this, empty, "autocommit"),
new ReflectiveCommandHandler(this, empty, "commit"),
new ReflectiveCommandHandler(this, new FileNameCompleter(),
"properties"),
new ReflectiveCommandHandler(this, empty, "rollback"),
new ReflectiveCommandHandler(this, empty, "help", "?"),
new ReflectiveCommandHandler(this, opts.optionCompleters(), "set"),
new ReflectiveCommandHandler(this, empty, "save"),
new ReflectiveCommandHandler(this, empty, "scan"),
new ReflectiveCommandHandler(this, empty, "sql"),
new ReflectiveCommandHandler(this, empty, "call"));
sqlLineCommandCompleter = new SqlLineCommandCompleter(this);
reflector = new Reflector(this);
opts.loadProperties(System.getProperties());
// attempt to dynamically load signal handler
try {
Class handlerClass = Class.forName("sqlline.SunSignalHandler");
signalHandler = (SqlLineSignalHandler) handlerClass.newInstance();
} catch (Throwable t) {
handleException(t);
}
}