With `CARGO_COMPLETE`, `--target`, `--bin`, etc show both values and flags
For example
This is because Cargo tells clap that these arguments take num_args(0..=1)
Cargo offers the 0-value variant for people to look up supported values
Options
- Remove the
num_args(0..=1)behavior - Somehow tell clap_complete about this special case
Combined with clap-rs/clap#5752, this makes it harder to see relevant completions on zsh
The Cargo team talked about this. Its not great we lie to clap to get the error reporting we want. If we want to keep our quality of errors is to then have a way to annotate clap with possible values that are dynamically generated from arg matches.
On clap's side, it wouldn't work to be context-aware because we validate num_args in the middle of parsing
https://github.com/clap-rs/clap/blob/61f5ee514f8f60ed8f04c6494bdf36c19e7a8126/clap_builder/src/parser/parser.rs#L1316-L1327
Another idea is to support cargo check --target ?. That requires name validation for any arguments to happen later (which I think is currently the case). This would also be treated as a glob if there is a single-letter file name.