Skip to content

Commit

Permalink
feat: Add custom completer for cargo help <TAB>
Browse files Browse the repository at this point in the history
  • Loading branch information
shannmu committed Sep 18, 2024
1 parent 0461165 commit f64411c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/bin/cargo/commands/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@ const COMPRESSED_MAN: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/man.tgz"
pub fn cli() -> Command {
subcommand("help")
.about("Displays help for a cargo subcommand")
.arg(Arg::new("COMMAND").action(ArgAction::Set))
.arg(Arg::new("COMMAND").action(ArgAction::Set).add(
clap_complete::ArgValueCandidates::new(|| {
super::builtin()
.iter()
.map(|cmd| {
let name = cmd.get_name();
clap_complete::CompletionCandidate::new(name)
.help(cmd.get_about().cloned())
.hide(cmd.is_hide_set())
})
.collect()
}),
))
}

pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
Expand Down

0 comments on commit f64411c

Please sign in to comment.