jline.console.completer.FileNameCompleter Java Examples

The following examples show how to use jline.console.completer.FileNameCompleter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CmdlineHelper.java    From clue with Apache License 2.0 7 votes vote down vote up
public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
                     Supplier<Collection<String>> fieldNameSupplier) throws IOException {
    consoleReader = new ConsoleReader();
    consoleReader.setBellEnabled(false);

    Collection<String> commands = commandNameSupplier != null
            ? commandNameSupplier.get() : Collections.emptyList();

    Collection<String> fields = fieldNameSupplier != null
            ? fieldNameSupplier.get() : Collections.emptyList();

    LinkedList<Completer> completors = new LinkedList<Completer>();
    completors.add(new StringsCompleter(commands));
    completors.add(new StringsCompleter(fields));
    completors.add(new FileNameCompleter());
    consoleReader.addCompleter(new ArgumentCompleter(completors));
}
 
Example #2
Source File: JLineDevice.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #3
Source File: MacroBaseSQLRepl.java    From macrobase with Apache License 2.0 5 votes vote down vote up
/**
 * Main entry point to the SQL CLI interface in MacroBase
 *
 * @param userWantsPaging try to enable paging of results in SQL shell
 * @throws IOException if unable to instantiate ConsoleReader
 */
private MacroBaseSQLRepl(final boolean userWantsPaging) throws IOException {
    // First try to turn paging on
    this.paging = enablePaging(userWantsPaging);
    // Initialize console reader and writer
    reader = new ConsoleReader();
    final CandidateListCompletionHandler handler = new CandidateListCompletionHandler();
    handler.setStripAnsi(true);
    reader.setCompletionHandler(handler);
    reader.addCompleter(new FileNameCompleter());

    parser = new SqlParser();
    queryEngine = new QueryEngine();
}
 
Example #4
Source File: Terminal.java    From cloudml with GNU Lesser General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #5
Source File: ClueCommandClient.java    From clue with Apache License 2.0 5 votes vote down vote up
public void run() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader();
    consoleReader.setBellEnabled(false);

    Collection<String> commands = getCommands();

    LinkedList<Completer> completors = new LinkedList<Completer>();
    completors.add(new StringsCompleter(commands));

    completors.add(new FileNameCompleter());

    consoleReader.addCompleter(new ArgumentCompleter(completors));



    while(true){
        String line = readCommand();
        if (line == null || line.isEmpty()) continue;
        line = line.trim();
        if ("exit".equals(line)) {
            System.exit(0);
        }
        String[] parts = line.split("\\s");
        if (parts.length > 0){
            String cmd = parts[0];
            String[] cmdArgs = new String[parts.length - 1];
            System.arraycopy(parts, 1, cmdArgs, 0, cmdArgs.length);
            handleCommand(cmd, cmdArgs, System.out);
        }
    }
}