Skip to content

Commit 403cc3d

Browse files
author
Paolo Tranquilli
committed
Rust: avoid cli flag defaults overriding env settings
1 parent 5ae8824 commit 403cc3d

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

rust/extractor/macros/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ pub fn extractor_cli_config(_attr: TokenStream, item: TokenStream) -> TokenStrea
1717
if p.path.is_ident(&format_ident!("bool")) {
1818
return quote! {
1919
#[arg(long)]
20+
#[serde(skip_serializing_if="<&bool>::not")]
2021
#id: bool,
2122
};
2223
}
2324
}
2425
if id == &format_ident!("verbose") {
2526
quote! {
2627
#[arg(long, short, action=clap::ArgAction::Count)]
28+
#[serde(skip_serializing_if="u8::is_zero")]
2729
#id: u8,
2830
}
2931
} else if id == &format_ident!("inputs") {

rust/extractor/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ use figment::{
55
providers::{Env, Serialized},
66
Figment,
77
};
8+
use num_traits::Zero;
89
use rust_extractor_macros::extractor_cli_config;
910
use serde::{Deserialize, Serialize};
11+
use std::ops::Not;
1012
use std::path::PathBuf;
1113

1214
#[derive(Debug, PartialEq, Eq, Default, Serialize, Deserialize, Clone, Copy, clap::ValueEnum)]

0 commit comments

Comments
 (0)