clap-rs / clap

A full featured, fast Command Line Argument Parser for Rust
docs.rs/clap
Apache License 2.0
14.4k stars 1.05k forks source link

Support delimited values for native completions #3922

Open epage opened 2 years ago

epage commented 2 years ago

See #3166 for more context

epage commented 3 months ago

@shannmu is there a reason #5602 didn't close this?

shannmu commented 3 months ago

The issue still seems to be related to allow_hyphen_values, where the completion for the delimited option includes the possible values of positional arguments (if they are also delimited). This is not caused by this issue, but it shows that the issue has not been fully resolved.

epage commented 3 months ago

I don't what allow_hyphen_values has to do with value_delimiter. I don't quite understand your explanation. Mind re-phrasing or providing examples?

shannmu commented 3 months ago

https://github.com/clap-rs/clap/blob/d81158599f5b3a2434845a1731377eae84780b9a/clap_complete/tests/testsuite/dynamic.rs#L673-L683

--delimiter=comma is treated as a delimited positional argument. We complete positional argument without conditions required when the current state is ValueDone, so it will call complete_arg_value. https://github.com/clap-rs/clap/blob/d81158599f5b3a2434845a1731377eae84780b9a/clap_complete/src/dynamic/complete.rs#L216-L221

epage commented 3 months ago

@shannmu I had missed that. If there is a known issue in a PR, call it out. That should have been discussed before merging.