org.codehaus.groovy.tools.shell.completion.CommandNameCompleter.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of groovy-all Show documentation
Show all versions of groovy-all Show documentation
Groovy: A powerful, dynamic language for the JVM
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
}
}