Closed jwodder closed 1 year ago
Thanks for pointing this out. I have improved the error messages and added some extra error checks.
To keep it compatible with both clap 3 and 4 I had to format the error by hand so there is no pretty colour coding, but the errors in 2.6 should be nicer:
error: Invalid value for --input <INPUT>: Could not open "/tmp/": Is a directory (os error 21)
error: Invalid value for --input <INPUT>: Could not open "/tmp/missingfile": No such file or directory (os error 2)
When using this crate with clap 4.0.18 and clap's default features, if a clio type returns an error (e.g., if a path supplied to an
Input
argument does not exist), then the resulting error message from clap will just be, e.g., "error: No such file or directory (os error 2)
" instead of the typical "error: Invalid value 'bad-path.txt' for '--infile <INFILE>': No such file or directory (os error 2)
".The only way I am aware of to fix this would be, in your
TypedValueParser
implementation, instead of converting to aclap::Error
usingInto
/?
, follow the error construction steps seen here. Unfortunately, this method does not seem to let you set a custom message or source error to display in the final error message, and I'm not even sure if it would work under clap 3.