Skip to content

Commit b9ea78f

Browse files
author
Paolo Tranquilli
committed
Rust: fix vector options
1 parent be45e3d commit b9ea78f

File tree

1 file changed

+14
-9
lines changed
  • rust/extractor/macros/src

1 file changed

+14
-9
lines changed

rust/extractor/macros/src/lib.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ pub fn extractor_cli_config(_attr: TokenStream, item: TokenStream) -> TokenStrea
1919
.fields
2020
.iter()
2121
.map(|f| {
22-
if get_type_tip(&f.ty).is_some_and(|i| i == "Vec") {
22+
if f.ident.as_ref().is_some_and(|i| i != "inputs")
23+
&& get_type_tip(&f.ty).is_some_and(|i| i == "Vec")
24+
{
2325
quote! {
2426
#[serde(deserialize_with="deserialize_newline_or_comma_separated")]
2527
#f
@@ -38,19 +40,17 @@ pub fn extractor_cli_config(_attr: TokenStream, item: TokenStream) -> TokenStrea
3840
let ty = &f.ty;
3941
let type_tip = get_type_tip(ty);
4042
if type_tip.is_some_and(|i| i == "bool") {
41-
return quote! {
43+
quote! {
4244
#[arg(long)]
4345
#[serde(skip_serializing_if="<&bool>::not")]
4446
#id: bool
45-
};
46-
}
47-
if type_tip.is_some_and(|i| i == "Option") {
48-
return quote! {
47+
}
48+
} else if type_tip.is_some_and(|i| i == "Option") {
49+
quote! {
4950
#[arg(long)]
5051
#f
51-
};
52-
}
53-
if id == &format_ident!("verbose") {
52+
}
53+
} else if id == &format_ident!("verbose") {
5454
quote! {
5555
#[arg(long, short, action=clap::ArgAction::Count)]
5656
#[serde(skip_serializing_if="u8::is_zero")]
@@ -60,6 +60,11 @@ pub fn extractor_cli_config(_attr: TokenStream, item: TokenStream) -> TokenStrea
6060
quote! {
6161
#f
6262
}
63+
} else if type_tip.is_some_and(|i| i == "Vec") {
64+
quote! {
65+
#[arg(long)]
66+
#id: Option<String>
67+
}
6368
} else {
6469
quote! {
6570
#[arg(long)]

0 commit comments

Comments
 (0)