Confusing validation message for free args
liamdawson opened this issue · comments
Given the following:
fn parse_username(input: &str) -> Result<String, String> {
// always fails
Err("Username is invalid!")
}
#[derive(Options)]
pub struct CliOptions {
#[options(free, parse(try_from_str = "parse_username"))]
pub username: String,
}
As of commit 121667e
, I get the following error message when passing a username (which is designed to fail, here):
[bin_name]: invalid argument to option `free`: Username is invalid!
I attempted to describe it using meta to change the identifier free
, but meta and free are mutually exclusive. Is there a way to change free
to username
, in this scenario?
I've just pushed a commit to fix this. Error messages for free argument values will now display the field name in the error message (without the use of meta
attribute, which is still invalid for free arguments).
Thanks for the issue.