本文整理汇总了Java中jline.console.completer.AggregateCompleter类的典型用法代码示例。如果您正苦于以下问题:Java AggregateCompleter类的具体用法?Java AggregateCompleter怎么用?Java AggregateCompleter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AggregateCompleter类属于jline.console.completer包,在下文中一共展示了AggregateCompleter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CommandCompleter
import jline.console.completer.AggregateCompleter; //导入依赖的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
示例2: CommandCompleter
import jline.console.completer.AggregateCompleter; //导入依赖的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);
}
示例3: resetCompletors
import jline.console.completer.AggregateCompleter; //导入依赖的package包/类
protected void resetCompletors() {
removeAllcompleters();
addcompleters(new AggregateCompleter(
Collections2.transform(commandMappings.keySet(), new Function<Call, Completer>() {
@Override
public Completer apply(final Call input) {
return new ArgumentCompleter(
ImmutableList.<Completer>builder()
.add(new StringsCompleter(input.commandName()))
.add(input.completers())
.build()
);
}
})
));
}
示例4: setCommands
import jline.console.completer.AggregateCompleter; //导入依赖的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);
}
示例5: initCommands
import jline.console.completer.AggregateCompleter; //导入依赖的package包/类
private void initCommands() {
List<Completer> compList = new ArrayList<>();
for (Class clazz : registeredCommands) {
TajoShellCommand cmd = null;
try {
Constructor cons = clazz.getConstructor(new Class[] {TajoCliContext.class});
cmd = (TajoShellCommand) cons.newInstance(context);
} catch (Exception e) {
System.err.println(e.getMessage());
throw new RuntimeException(e.getMessage());
}
// make completers for console auto-completion
compList.add(cmd.getArgumentCompleter());
commands.put(cmd.getCommand(), cmd);
for (String alias : cmd.getAliases()) {
commands.put(alias, cmd);
}
}
cliCompleter = new AggregateCompleter(compList);
sqlCompleter = new ArgumentCompleter(
new ArgumentCompleter.AbstractArgumentDelimiter() {
@Override
public boolean isDelimiterChar(CharSequence buf, int pos) {
char c = buf.charAt(pos);
return Character.isWhitespace(c) || !(Character.isLetterOrDigit(c)) && c != '_';
}
},
new StringsCompleter(getKeywords())
);
}
示例6: setupCompleter
import jline.console.completer.AggregateCompleter; //导入依赖的package包/类
private void setupCompleter(ConsoleReader reader)
{
reader.addCompleter(new AggregateCompleter(defaultCompleters()));
}
示例7: Init
import jline.console.completer.AggregateCompleter; //导入依赖的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);
}
}
});
}