mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
bfa02fd418
This ports our example testing over to [trycmd](https://docs.rs/) so we can: - More thoroughly test our examples - Provide always-up-to-date example usage The old way of testing automatically picked up examples. This new way requires we have a `.md` file that uses the example in some way. Notes: - Moved overall example description to the `.md` file - I added cross-linking between related examples - `14_groups` had a redundant paragraph (twice talked about "one and only one"
493 B
493 B
You can define a function (or a closure) to use as a validator to argument values. The
function must accept a &str
and return Result<(), String>
where Err(String)
is the
message displayed to the user.
$ 15_custom_validator input.png
The .PNG file is: input.png
$ 15_custom_validator input.txt
? failed
error: Invalid value for '<input>': the file format must be png.
For more information try --help
This is especially useful when using custom types.