refactor: changes validator signature to match v3

This commit is contained in:
Kevin K 2018-07-12 20:03:04 -04:00
parent 1b257f54b8
commit cbd378e539
No known key found for this signature in database
GPG key ID: 17218E4B3692F01A

View file

@ -88,7 +88,7 @@ fn test_parse_hex() {
fn custom_parser_1(_: &str) -> &'static str { "A" } fn custom_parser_1(_: &str) -> &'static str { "A" }
fn custom_parser_2(_: &str) -> Result<&'static str, u32> { Ok("B") } fn custom_parser_2(_: &str) -> Result<&'static str, u32> { Ok("B") }
fn custom_parser_3(_: &OsStr) -> &'static str { "C" } fn custom_parser_3(_: &OsStr) -> &'static str { "C" }
fn custom_parser_4(_: &OsStr) -> Result<&'static str, OsString> { Ok("D") } fn custom_parser_4(_: &OsStr) -> Result<&'static str, String> { Ok("D") }
#[derive(Clap, PartialEq, Debug)] #[derive(Clap, PartialEq, Debug)]
struct NoOpOpt { struct NoOpOpt {
@ -172,7 +172,11 @@ struct Occurrences {
#[clap(short = "r", parse(from_occurrences))] #[clap(short = "r", parse(from_occurrences))]
little_unsigned: u8, little_unsigned: u8,
#[clap(short = "c", long = "custom", parse(from_occurrences = "foo"))] #[clap(
short = "c",
long = "custom",
parse(from_occurrences = "foo")
)]
custom: Foo, custom: Foo,
} }
@ -205,7 +209,11 @@ fn test_custom_bool() {
struct Opt { struct Opt {
#[clap(short = "d", parse(try_from_str = "parse_bool"))] #[clap(short = "d", parse(try_from_str = "parse_bool"))]
debug: bool, debug: bool,
#[clap(short = "v", default_value = "false", parse(try_from_str = "parse_bool"))] #[clap(
short = "v",
default_value = "false",
parse(try_from_str = "parse_bool")
)]
verbose: bool, verbose: bool,
#[clap(short = "t", parse(try_from_str = "parse_bool"))] #[clap(short = "t", parse(try_from_str = "parse_bool"))]
tribool: Option<bool>, tribool: Option<bool>,