Closed mwlon closed 1 week ago
This isn't value_parser
but our derive code which is inferring behavior based on types. You can workaround it by fully qualifying Option
.
See #4626 for improving this.
Thanks, I was able to work around it using that trick. I'll close this issue since #4626 probably covers it.
Please complete the following tasks
Rust Version
1.79
Clap Version
4.5.3
Minimal reproducible code
Steps to reproduce the bug with the above code
cargo run -- --foo=auto
Actual Behaviour
something like
Expected Behaviour
happy 0 exit code
Additional Context
It appears that clap derive expects
parse_foo
to just returnusize
instead ofOption<usize>
, and if we change it to do that, the above code compiles. This might make sense for singly-nestedOption<usize>
, but definitely seems wrong forOption<Option<usize>>
. I assume this isn't the desired behavior; if it is, I think an explanation is warranted. I couldn't find any mention of howvalue_parser
interacts withOption<>
typing from the docs, but it's always possible I missed something.Side question: if I want the above behavior where
"auto"
or no arg =>None
, int_string =>Some(int)
, is there a better way to do it? I would prefer not to define an enum.Debug Output
No response