mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 23:37:32 +00:00
Make multiple_values
false with Option<Option<...>>
This commit is contained in:
parent
4bec66dd03
commit
eca8ba6098
2 changed files with 16 additions and 1 deletions
|
@ -264,9 +264,9 @@ pub fn gen_augment(
|
|||
Ty::OptionOption => quote_spanned! { ty.span()=>
|
||||
.takes_value(true)
|
||||
#value_name
|
||||
.multiple_values(false)
|
||||
.min_values(0)
|
||||
.max_values(1)
|
||||
.multiple_values(false)
|
||||
#validator
|
||||
},
|
||||
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
|
||||
#![allow(clippy::option_option)]
|
||||
|
||||
mod utils;
|
||||
|
||||
use clap::Clap;
|
||||
use utils::*;
|
||||
|
||||
#[test]
|
||||
fn required_option() {
|
||||
|
@ -135,6 +138,18 @@ fn optional_argument_for_optional_option() {
|
|||
assert!(Opt::try_parse_from(&["test", "-a42", "-a24"]).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn option_option_help() {
|
||||
#[derive(Clap, Debug)]
|
||||
struct Opt {
|
||||
#[clap(long, value_name = "val")]
|
||||
arg: Option<Option<i32>>,
|
||||
}
|
||||
let help = get_help::<Opt>();
|
||||
assert!(help.contains("--arg <val>"));
|
||||
assert!(!help.contains("--arg <val>..."));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_option_options() {
|
||||
#[derive(Clap, PartialEq, Debug)]
|
||||
|
|
Loading…
Add table
Reference in a new issue