當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。