All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.groovy.tools.shell.completion.CommandNameCompleter.groovy Maven / Gradle / Ivy

There is a newer version: 3.0.22
Show newest version
package org.codehaus.groovy.tools.shell.completion

import org.codehaus.groovy.tools.shell.Command
import org.codehaus.groovy.tools.shell.CommandRegistry
import org.codehaus.groovy.tools.shell.util.SimpleCompletor

/**
 * Completor for the command.names
 *
 * @version $Id$
 * @author Jason Dillon
 */
class CommandNameCompleter extends SimpleCompletor {
    private final CommandRegistry registry

    CommandNameCompleter(final CommandRegistry registry) {
        assert registry

        this.registry = registry
    }

    SortedSet getCandidates() {
        def set = new TreeSet()

        for (Command command in registry.commands()) {
            if (command.hidden) {
                continue
            }

            set << command.name
            set << command.shortcut
        }

        return set
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy