Skip to content

Commit

Permalink
ConsoleEngineImpl: exclude pipe name aliases from command completion
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Nov 15, 2020
1 parent df99187 commit 495b534
Showing 1 changed file with 11 additions and 1 deletion.
Expand Up @@ -23,6 +23,7 @@
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.jline.builtins.Completers.FilesCompleter;
import org.jline.builtins.Completers.OptDesc;
Expand Down Expand Up @@ -186,10 +187,19 @@ public List<Completer> scriptCompleters() {
, this::commandOptions
, 1)
));
out.add(new ArgumentCompleter(new StringsCompleter(aliases::keySet), NullCompleter.INSTANCE));
out.add(new ArgumentCompleter(new StringsCompleter(this::commandAliasNames)
, NullCompleter.INSTANCE));
return out;
}

private Set<String> commandAliasNames() {
Set<String> opers = pipes.keySet().stream().filter(p -> !p.matches("\\w+")).collect(Collectors.toSet());
opers.addAll(systemRegistry.getPipeNames());
return aliases.entrySet().stream()
.filter(e -> !opers.contains(e.getValue().split(" ")[0]))
.map(Map.Entry::getKey).collect(Collectors.toSet());
}

private Set<String> scriptNames() {
return scripts().keySet();
}
Expand Down

0 comments on commit 495b534

Please sign in to comment.