Skip to content

Commit 48ff72b

Browse files
committed
fix(complete): Deduplicate bash subcmd cases
**Problem:** Visible alias completions were causing duplicate case conditions when offering subcommand completions, due to the fact that they share the same function name as the command they are aliasing. **Solution:** Deduplicate them so as to not redefine the exact same case statement logic.
1 parent b1b6f17 commit 48ff72b

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

clap_complete/src/aot/shells/bash.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ fn subcommand_details(cmd: &Command) -> String {
132132
.collect::<Vec<_>>();
133133

134134
scs.sort();
135+
scs.dedup();
135136

136137
subcmd_dets.extend(scs.iter().map(|sc| {
137138
format!(

clap_complete/tests/snapshots/sub_subcommands.bash

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,6 @@ _my-app() {
152152
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
153153
return 0
154154
;;
155-
my__app__some_cmd)
156-
opts="-h -V --help --version sub_cmd help"
157-
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
158-
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
159-
return 0
160-
fi
161-
case "${prev}" in
162-
*)
163-
COMPREPLY=()
164-
;;
165-
esac
166-
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
167-
return 0
168-
;;
169155
my__app__some_cmd__help)
170156
opts="sub_cmd help"
171157
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy