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


Java StringsCompleter类代码示例

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


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

示例1: getConsole

import jline.console.completer.StringsCompleter; //导入依赖的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;
}
 
开发者ID:needle-wang,项目名称:jweevely,代码行数:24,代码来源:JweevelyClient.java

示例2: connect

import jline.console.completer.StringsCompleter; //导入依赖的package包/类
public void connect(int port) throws IOException {
    socket = new Socket("localhost", port);
    packer = msgpack.createPacker(socket.getOutputStream());
    unpacker = msgpack.createUnpacker(socket.getInputStream());

    packer.write("/?\n");
    List<String> availableCommands = new ArrayList<>();
    while (true) {
        ReplResponse res = unpacker.read(ReplResponse.class);
        if (res.getOut() != null) {
            Stream.of(res.getOut())
                    .map(String::trim)
                    .filter(s -> s.startsWith("/"))
                    .forEach(availableCommands::add);
        }

        if (res.getStatus().contains(DONE)) {
            break;
        }
    }
    console.addCompleter(new StringsCompleter(availableCommands));
    console.println("Connected to server (port = " + port +")");
    console.flush();
}
 
开发者ID:kawasima,项目名称:enkan,代码行数:25,代码来源:ReplClient.java

示例3: CommandCompleter

import jline.console.completer.StringsCompleter; //导入依赖的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

示例4: initConsole

import jline.console.completer.StringsCompleter; //导入依赖的package包/类
public static ConsoleReader initConsole() throws IOException, InvalidColourException{
	
	Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
	    public void run() {
	    	System.out.print("\033[0m"); // On exit turn off all formatting
	    }
	}));
	
	ConsoleReader console= new ConsoleReader(); 

	try {
		// Autcomplete commands with length > x 
		for(CommandHelp x : CommandList.commandHelpList()){
			if(x.getName().length() > 2){
				console.addCompleter(new StringsCompleter(x.getName()));
			}
		}
	} catch (InvalidCommandLineException e) {
		e.printStackTrace();
	}
	console.setExpandEvents(false);
	return console;
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:24,代码来源:Main.java

示例5: CommandCompleter

import jline.console.completer.StringsCompleter; //导入依赖的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);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:21,代码来源:CommandCompleter.java

示例6: buildInstance

import jline.console.completer.StringsCompleter; //导入依赖的package包/类
public static HeroicInteractiveShell buildInstance(
    final List<CommandDefinition> commands, FileInputStream input
) throws Exception {
    final ConsoleReader reader = new ConsoleReader("heroicsh", input, System.out, null);

    final FileHistory history = setupHistory(reader);

    if (history != null) {
        reader.setHistory(history);
    }

    reader.setPrompt(String.format("heroic> "));
    reader.addCompleter(new StringsCompleter(
        ImmutableList.copyOf(commands.stream().map((d) -> d.getName()).iterator())));
    reader.setHandleUserInterrupt(true);

    return new HeroicInteractiveShell(reader, commands, history);
}
 
开发者ID:spotify,项目名称:heroic,代码行数:19,代码来源:HeroicInteractiveShell.java

示例7: readCommands

import jline.console.completer.StringsCompleter; //导入依赖的package包/类
public void readCommands() {
    try {
        console = new ConsoleReader();
        List commandNames = new ArrayList();
        for (Command c : commands) {
            c.setupCompleter();
            commandNames.add(c.names[0]);
        }
        console.addCompleter(new StringsCompleter(commandNames));
        console.setPrompt("proptester> ");
        String line;
        while ((line = console.readLine()) != null) {
            processCommand(line);
        }
    } catch (IOException io) {
        io.printStackTrace();
    }
}
 
开发者ID:Talend,项目名称:components,代码行数:19,代码来源:PropertiesTester.java

示例8: initConsole

import jline.console.completer.StringsCompleter; //导入依赖的package包/类
/**
 * Console initialisation.
 */
private void initConsole() {

    try {
        reader = new ConsoleReader();
        final StringsCompleter strCompleter = new StringsCompleter(
                "examples", "quit", "exit", "select", "insert", "update", "drop", "show" );

        reader.setPrompt(" > ");
        reader.addCompleter(strCompleter);

    }
    catch (IOException e) {
        logger.error("Init de la console", e);
        System.exit(1);
    }
}
 
开发者ID:bbonnin,项目名称:hadoop-mongodb,代码行数:20,代码来源:HiveShell.java

示例9: SqlLineCommandCompleter

import jline.console.completer.StringsCompleter; //导入依赖的package包/类
public SqlLineCommandCompleter(SqlLine sqlLine) {
  List<ArgumentCompleter> completers = new LinkedList<ArgumentCompleter>();

  for (CommandHandler commandHandler : sqlLine.commandHandlers) {
    for (String cmd : commandHandler.getNames()) {
      List<Completer> compl = new LinkedList<Completer>();
      compl.add(new StringsCompleter(SqlLine.COMMAND_PREFIX + cmd));
      compl.addAll(commandHandler.getParameterCompleters());
      compl.add(new NullCompleter()); // last param no complete

      completers.add(new ArgumentCompleter(compl));
    }
  }

  getCompleters().addAll(completers);
}
 
开发者ID:mozafari,项目名称:verdict,代码行数:17,代码来源:SqlLineCommandCompleter.java

示例10: console

import jline.console.completer.StringsCompleter; //导入依赖的package包/类
private void console() throws Exception {
        reader = new ConsoleReader();
        consoleMode = true;
        reader.setBellEnabled(false);
//        List<Completer> completors = new LinkedList<>();
        List<String> commandNames = commands.stream().map(Command::getName).collect(toList());
        commandNames.add("exit");
        reader.addCompleter(new StringsCompleter(commandNames));
//        reader.addCompleter(new ArgumentCompleter(completors));
        String line;
        PrintWriter out = new PrintWriter(reader.getOutput());

        while ((line = readLine("hightide")) != null) {
            if ("exit".equals(line)) {
                exit();
                return;
            } else {
                Boolean failed = !runCommand(line);
                if (failed) {
                    System.out
                            .println("Invalid command, For assistance press TAB or type \"help\" then hit ENTER.");
                }
            }
            out.flush();
        }
    }
 
开发者ID:gzlabs,项目名称:hightide,代码行数:27,代码来源:HightideShell.java

示例11: resetCompletors

import jline.console.completer.StringsCompleter; //导入依赖的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()
                );
            }
        })
    ));
}
 
开发者ID:shopzilla,项目名称:hadoop-in-a-box,代码行数:17,代码来源:HadoopREPL.java

示例12: Init

import jline.console.completer.StringsCompleter; //导入依赖的package包/类
/** Client initialization */
public void Init( String url ) {

    if( url != null && !url.equals( "" ) )
        _server_url = url;

    try {
        _servidor = new XmlRpcClientBase( _server_url );

        _reader = new ConsoleReader();
        _reader.setBellEnabled( false );
        List completors = new LinkedList();

        completors.add( new StringsCompleter( _commandList ) );
        _reader.addCompleter( new ArgumentCompleter( completors ) );

    } catch (Exception exception) {
        System.err.println("error: " + exception.toString());
    }
}
 
开发者ID:jenbabis22,项目名称:MXCashMarketDataDrv,代码行数:21,代码来源:DriverClient.java

示例13: setUpCompletors

import jline.console.completer.StringsCompleter; //导入依赖的package包/类
/**
 * sets up the completors that a user can use with tab
 * @param reader  the current reader
 */
private void setUpCompletors(ConsoleReader reader) {
    List<Completer> completors = new LinkedList<>();
    completors.add(new StringsCompleter("create", "start", "stop", "exit", "help", "cls"));
    for (Completer c : completors) {
        reader.addCompleter(c);
    }
}
 
开发者ID:StuPro-TOSCAna,项目名称:stupro_toscana_vorprojekt,代码行数:12,代码来源:Controller.java

示例14: testStringsCompleter

import jline.console.completer.StringsCompleter; //导入依赖的package包/类
@Test
public void testStringsCompleter() {
    StringsCompleter completer = new StringsCompleter("abc", "abd", "ac");
    List<CharSequence> candidates = new ArrayList<>();
    completer.complete("a", 1, candidates);
    System.out.println(candidates);
    candidates.clear();
    completer.complete("ab", 2, candidates);
    System.out.println(candidates);
}
 
开发者ID:kawasima,项目名称:enkan,代码行数:11,代码来源:CompleterTest.java

示例15: init

import jline.console.completer.StringsCompleter; //导入依赖的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");
}
 
开发者ID:JackWhite20,项目名称:JaPS,代码行数:37,代码来源:JaPS.java


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