From 8b2f08cc88395ac91f4f3b39387d9913462ec451 Mon Sep 17 00:00:00 2001 From: shannmu Date: Wed, 14 Aug 2024 16:22:12 +0800 Subject: [PATCH] feat: Add custom completer for `cargo -Z ` --- src/bin/cargo/cli.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index de1653e39ad..9cc0401a31c 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -682,7 +682,15 @@ See 'cargo help <>' for more information on a sp .short('Z') .value_name("FLAG") .action(ArgAction::Append) - .global(true)) + .global(true) + .add(clap_complete::ArgValueCandidates::new(|| { + let flags = CliUnstable::help(); + flags.into_iter().map(|flag| { + clap_complete::CompletionCandidate::new(flag.0.replace("_", "-")).help(flag.1.map(|help| { + help.into() + })) + }).collect() + }))) .subcommands(commands::builtin()) }