Skip to content

Commit 082a278

Browse files
committed
refactor(cli): Generalize completion code
1 parent 09a472e commit 082a278

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/bin/cargo/cli.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ See '<bright-cyan,bold>cargo help</> <cyan><<command>></>' for more information
704704
.map(|t| clap_complete::CompletionCandidate::new(t))
705705
.collect::<Vec<_>>();
706706
if let Ok(gctx) = new_gctx_for_completions() {
707-
candidates.extend(get_alias_candidates(&gctx));
707+
candidates.extend(get_command_candidates(&gctx));
708708
}
709709
candidates
710710
}))
@@ -728,11 +728,11 @@ fn get_toolchains_from_rustup() -> Vec<String> {
728728
stdout.lines().map(|line| format!("+{}", line)).collect()
729729
}
730730

731-
fn get_alias_candidates(gctx: &GlobalContext) -> Vec<clap_complete::CompletionCandidate> {
732-
let alias_map = user_defined_aliases(gctx);
733-
alias_map
731+
fn get_command_candidates(gctx: &GlobalContext) -> Vec<clap_complete::CompletionCandidate> {
732+
let commands = user_defined_aliases(gctx);
733+
commands
734734
.iter()
735-
.map(|(alias, cmd_info)| {
735+
.map(|(name, cmd_info)| {
736736
let help_text = match cmd_info {
737737
CommandInfo::Alias { target } => {
738738
let cmd_str = target
@@ -749,7 +749,7 @@ fn get_alias_candidates(gctx: &GlobalContext) -> Vec<clap_complete::CompletionCa
749749
unreachable!("External command shouldn't appear in alias map")
750750
}
751751
};
752-
clap_complete::CompletionCandidate::new(alias.clone()).help(Some(help_text.into()))
752+
clap_complete::CompletionCandidate::new(name.clone()).help(Some(help_text.into()))
753753
})
754754
.collect()
755755
}

0 commit comments

Comments
 (0)