Skip to content

Commit

Permalink
fix(derive): Transition off of multiple_occurrences
Browse files Browse the repository at this point in the history
For programs opting into the clap v4 behavior (with `action` or
`value_parser` attributes), we'll no longer generate a
`multiple_occurrences(true)` call in preparation for deprecating
`multiple_occurrences`.  See clap-rs#3772.
  • Loading branch information
epage committed Jun 7, 2022
1 parent efc1520 commit 19d8ca8
Showing 1 changed file with 65 additions and 17 deletions.
82 changes: 65 additions & 17 deletions clap_derive/src/derives/args.rs
Expand Up @@ -304,25 +304,73 @@ pub fn gen_augment(
#action
},

Ty::OptionVec => quote_spanned! { ty.span()=>
.takes_value(true)
.value_name(#value_name)
.multiple_occurrences(true)
#possible_values
#validator
#value_parser
#action
},
Ty::OptionVec => {
if attrs.ignore_parser() {
if attrs.is_positional() {
quote_spanned! { ty.span()=>
.takes_value(true)
.value_name(#value_name)
.multiple_values(true) // action won't be sufficient for getting multiple
#possible_values
#validator
#value_parser
#action
}
} else {
quote_spanned! { ty.span()=>
.takes_value(true)
.value_name(#value_name)
#possible_values
#validator
#value_parser
#action
}
}
} else {
quote_spanned! { ty.span()=>
.takes_value(true)
.value_name(#value_name)
.multiple_occurrences(true)
#possible_values
#validator
#value_parser
#action
}
}
}

Ty::Vec => {
quote_spanned! { ty.span()=>
.takes_value(true)
.value_name(#value_name)
.multiple_occurrences(true)
#possible_values
#validator
#value_parser
#action
if attrs.ignore_parser() {
if attrs.is_positional() {
quote_spanned! { ty.span()=>
.takes_value(true)
.value_name(#value_name)
.multiple_values(true) // action won't be sufficient for getting multiple
#possible_values
#validator
#value_parser
#action
}
} else {
quote_spanned! { ty.span()=>
.takes_value(true)
.value_name(#value_name)
#possible_values
#validator
#value_parser
#action
}
}
} else {
quote_spanned! { ty.span()=>
.takes_value(true)
.value_name(#value_name)
.multiple_occurrences(true)
#possible_values
#validator
#value_parser
#action
}
}
}

Expand Down

0 comments on commit 19d8ca8

Please sign in to comment.