Skip to content

Commit e64e8aa

Browse files
committed
feat(cli): Allow completions for third-party subcommand names
1 parent 082a278 commit e64e8aa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/bin/cargo/cli.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::fmt::Write;
1111

1212
use super::commands;
1313
use super::list_commands;
14+
use super::third_party_subcommands;
1415
use super::user_defined_aliases;
1516
use crate::command_prelude::*;
1617
use crate::util::is_rustup;
@@ -729,7 +730,8 @@ fn get_toolchains_from_rustup() -> Vec<String> {
729730
}
730731

731732
fn get_command_candidates(gctx: &GlobalContext) -> Vec<clap_complete::CompletionCandidate> {
732-
let commands = user_defined_aliases(gctx);
733+
let mut commands = user_defined_aliases(gctx);
734+
commands.extend(third_party_subcommands(gctx));
733735
commands
734736
.iter()
735737
.map(|(name, cmd_info)| {
@@ -745,8 +747,8 @@ fn get_command_candidates(gctx: &GlobalContext) -> Vec<clap_complete::Completion
745747
CommandInfo::BuiltIn { .. } => {
746748
unreachable!("BuiltIn command shouldn't appear in alias map")
747749
}
748-
CommandInfo::External { .. } => {
749-
unreachable!("External command shouldn't appear in alias map")
750+
CommandInfo::External { path } => {
751+
format!("from {}", path.display())
750752
}
751753
};
752754
clap_complete::CompletionCandidate::new(name.clone()).help(Some(help_text.into()))

0 commit comments

Comments
 (0)