Skip to content

Commit

Permalink
test(derive): Update for deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed May 25, 2022
1 parent 814d30b commit 408ca3c
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 32 deletions.
2 changes: 1 addition & 1 deletion tests/derive_ui/default_value_t_invalid.rs
Expand Up @@ -11,7 +11,7 @@ use clap::Parser;
#[derive(Parser, Debug)]
#[clap(name = "basic")]
struct Opt {
#[clap(default_value_t = -10)]
#[clap(value_parser, default_value_t = -10)]
value: u32,
}

Expand Down
6 changes: 3 additions & 3 deletions tests/derive_ui/default_value_t_invalid.stderr
@@ -1,7 +1,7 @@
error[E0600]: cannot apply unary operator `-` to type `u32`
--> $DIR/default_value_t_invalid.rs:14:30
--> $DIR/default_value_t_invalid.rs:14:44
|
14 | #[clap(default_value_t = -10)]
| ^^^ cannot apply unary operator `-`
14 | #[clap(value_parser, default_value_t = -10)]
| ^^^ cannot apply unary operator `-`
|
= note: unsigned values cannot be negated
4 changes: 2 additions & 2 deletions tests/derive_ui/flatten_and_methods.rs
Expand Up @@ -10,9 +10,9 @@ use clap::Parser;

#[derive(Parser, Debug)]
struct DaemonOpts {
#[clap(short)]
#[clap(short, value_parser)]
user: String,
#[clap(short)]
#[clap(short, value_parser)]
group: String,
}

Expand Down
4 changes: 2 additions & 2 deletions tests/derive_ui/flatten_and_parse.rs
Expand Up @@ -10,9 +10,9 @@ use clap::Parser;

#[derive(Parser, Debug)]
struct DaemonOpts {
#[clap(short)]
#[clap(short, value_parser)]
user: String,
#[clap(short)]
#[clap(short, value_parser)]
group: String,
}

Expand Down
9 changes: 6 additions & 3 deletions tests/derive_ui/skip_flatten.rs
Expand Up @@ -11,7 +11,7 @@ use clap::Parser;
#[derive(Parser, Debug)]
#[clap(name = "make-cookie")]
struct MakeCookie {
#[clap(short)]
#[clap(short, value_parser)]
s: String,

#[clap(skip, flatten)]
Expand All @@ -22,10 +22,13 @@ struct MakeCookie {
enum Command {
#[clap(name = "pound")]
/// Pound acorns into flour for cookie dough.
Pound { acorns: u32 },
Pound {
#[clap(value_parser)]
acorns: u32,
},

Sparkle {
#[clap(short)]
#[clap(short, value_parser)]
color: String,
},
}
Expand Down
9 changes: 6 additions & 3 deletions tests/derive_ui/skip_subcommand.rs
Expand Up @@ -11,7 +11,7 @@ use clap::Parser;
#[derive(Parser, Debug)]
#[clap(name = "make-cookie")]
struct MakeCookie {
#[clap(short)]
#[clap(short, value_parser)]
s: String,

#[clap(subcommand, skip)]
Expand All @@ -22,10 +22,13 @@ struct MakeCookie {
enum Command {
#[clap(name = "pound")]
/// Pound acorns into flour for cookie dough.
Pound { acorns: u32 },
Pound {
#[clap(value_parser)]
acorns: u32,
},

Sparkle {
#[clap(short)]
#[clap(short, value_parser)]
color: String,
},
}
Expand Down
2 changes: 1 addition & 1 deletion tests/derive_ui/skip_without_default.rs
Expand Up @@ -17,7 +17,7 @@ enum Kind {
#[derive(Parser, Debug)]
#[clap(name = "test")]
pub struct Opt {
#[clap(short)]
#[clap(short, value_parser)]
number: u32,
#[clap(skip)]
k: Kind,
Expand Down
2 changes: 1 addition & 1 deletion tests/derive_ui/struct_parse.rs
Expand Up @@ -11,7 +11,7 @@ use clap::Parser;
#[derive(Parser, Debug)]
#[clap(name = "basic", parse(from_str))]
struct Opt {
#[clap(short)]
#[clap(short, value_parser)]
s: String,
}

Expand Down
2 changes: 1 addition & 1 deletion tests/derive_ui/struct_subcommand.rs
Expand Up @@ -11,7 +11,7 @@ use clap::Parser;
#[derive(Parser, Debug)]
#[clap(name = "basic", subcommand)]
struct Opt {
#[clap(short)]
#[clap(short, value_parser)]
s: String,
}

Expand Down
9 changes: 6 additions & 3 deletions tests/derive_ui/subcommand_and_flatten.rs
Expand Up @@ -10,7 +10,7 @@ use clap::Parser;

#[derive(Parser, Debug)]
struct MakeCookie {
#[clap(short)]
#[clap(short, value_parser)]
s: String,

#[clap(subcommand, flatten)]
Expand All @@ -20,10 +20,13 @@ struct MakeCookie {
#[derive(Parser, Debug)]
enum Command {
/// Pound acorns into flour for cookie dough.
Pound { acorns: u32 },
Pound {
#[clap(value_parser)]
acorns: u32,
},

Sparkle {
#[clap(short)]
#[clap(short, value_parser)]
color: String,
},
}
Expand Down
9 changes: 6 additions & 3 deletions tests/derive_ui/subcommand_and_methods.rs
Expand Up @@ -10,7 +10,7 @@ use clap::Parser;

#[derive(Parser, Debug)]
struct MakeCookie {
#[clap(short)]
#[clap(short, value_parser)]
s: String,

#[clap(subcommand, long)]
Expand All @@ -20,10 +20,13 @@ struct MakeCookie {
#[derive(Parser, Debug)]
enum Command {
/// Pound acorns into flour for cookie dough.
Pound { acorns: u32 },
Pound {
#[clap(value_parser)]
acorns: u32,
},

Sparkle {
#[clap(short)]
#[clap(short, value_parser)]
color: String,
},
}
Expand Down
9 changes: 6 additions & 3 deletions tests/derive_ui/subcommand_and_parse.rs
Expand Up @@ -10,7 +10,7 @@ use clap::Parser;

#[derive(Parser, Debug)]
struct MakeCookie {
#[clap(short)]
#[clap(short, value_parser)]
s: String,

#[clap(subcommand, parse(from_occurrences))]
Expand All @@ -20,10 +20,13 @@ struct MakeCookie {
#[derive(Parser, Debug)]
enum Command {
/// Pound acorns into flour for cookie dough.
Pound { acorns: u32 },
Pound {
#[clap(value_parser)]
acorns: u32,
},

Sparkle {
#[clap(short)]
#[clap(short, value_parser)]
color: String,
},
}
Expand Down
9 changes: 6 additions & 3 deletions tests/derive_ui/subcommand_opt_opt.rs
Expand Up @@ -10,7 +10,7 @@ use clap::Parser;

#[derive(Parser, Debug)]
struct MakeCookie {
#[clap(short)]
#[clap(short, value_parser)]
s: String,

#[clap(subcommand)]
Expand All @@ -20,10 +20,13 @@ struct MakeCookie {
#[derive(Parser, Debug)]
enum Command {
/// Pound acorns into flour for cookie dough.
Pound { acorns: u32 },
Pound {
#[clap(value_parser)]
acorns: u32,
},

Sparkle {
#[clap(short)]
#[clap(short, value_parser)]
color: String,
},
}
Expand Down
9 changes: 6 additions & 3 deletions tests/derive_ui/subcommand_opt_vec.rs
Expand Up @@ -10,7 +10,7 @@ use clap::Parser;

#[derive(Parser, Debug)]
struct MakeCookie {
#[clap(short)]
#[clap(short, value_parser)]
s: String,

#[clap(subcommand)]
Expand All @@ -20,10 +20,13 @@ struct MakeCookie {
#[derive(Parser, Debug)]
enum Command {
/// Pound acorns into flour for cookie dough.
Pound { acorns: u32 },
Pound {
#[clap(value_parser)]
acorns: u32,
},

Sparkle {
#[clap(short)]
#[clap(short, value_parser)]
color: String,
},
}
Expand Down

0 comments on commit 408ca3c

Please sign in to comment.