Skip to content

Commit

Permalink
[#2331] Bugfix: AutoComplete with jline3 was showing hidden commands
Browse files Browse the repository at this point in the history
Closes #2331
  • Loading branch information
remkop committed Aug 31, 2024
1 parent 7852b50 commit 2e7ce24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Artifacts in this release are signed by Remko Popma (6601 E5C0 8DCC BB96).

## <a name="4.7.7-fixes"></a> Fixed issues

* [#2335] Module info missing in all jars except the main picocli jar file. Thanks to [Oliver B. Fischer](https://github.com/obfischer) for raising this.
* [#2335] Bugfix: Module info missing in all jars except the main picocli jar file. Thanks to [Oliver B. Fischer](https://github.com/obfischer) for raising this.
* [#2331] Bugfix: AutoComplete with jline3 was showing hidden commands. Thanks to [clebertsuconic](https://github.com/clebertsuconic) for raising this.
* [#2290] DOC: User guide, CDI 2.0 (JSR 365) section: fix example and add warning about dynamic proxies. Thanks to [Mert Zeybekler](https://github.com/Mert-Z) for the pull request.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -170,7 +171,7 @@ public void complete(LineReader reader, ParsedLine commandLine, List<Candidate>
String word = commandLine.word();
List<String> words = commandLine.words();
CommandLine sub = findSubcommandLine(words, commandLine.wordIndex());
if (sub == null) {
if (sub == null || sub.getCommandSpec().usageMessage().hidden()) {
return;
}
if (word.startsWith("-")) {
Expand All @@ -192,9 +193,9 @@ public void complete(LineReader reader, ParsedLine commandLine, List<Candidate>
}
}
} else {
addCandidates(candidates, sub.getSubcommands().keySet());
for (CommandLine s : sub.getSubcommands().values()) {
if (!s.getCommandSpec().usageMessage().hidden()) {
addCandidates(candidates, Collections.singletonList(s.getCommandSpec().name()));
addCandidates(candidates, Arrays.asList(s.getCommandSpec().aliases()));
}
}
Expand Down

0 comments on commit 2e7ce24

Please sign in to comment.