Skip to content

Commit 5e57cdc

Browse files
committed
test override
1 parent 50e3720 commit 5e57cdc

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/cli.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub struct InfoCliOptions {
5656
value_enum,
5757
value_name = "FIELD"
5858
)]
59-
pub disabled_fields: Vec<InfoType>,
59+
pub disabled_fields: Option<Vec<InfoType>>,
6060
/// Hides the title
6161
#[arg(long)]
6262
pub no_title: bool,
@@ -280,7 +280,7 @@ impl Default for InfoCliOptions {
280280
hide_token: Default::default(),
281281
include_hidden: Default::default(),
282282
r#type: vec![LanguageType::Programming, LanguageType::Markup],
283-
disabled_fields: Vec::default(),
283+
disabled_fields: Some(Vec::default()),
284284
no_title: Default::default(),
285285
}
286286
}
@@ -321,7 +321,11 @@ impl Default for ConfigCliOptions {
321321
fn default() -> Self {
322322
ConfigCliOptions {
323323
// Not sure about unwrap
324-
config_path: Some(dirs::config_dir().expect("Could not find $HOME!").join("onefetch/config.toml")),
324+
config_path: Some(
325+
dirs::config_dir()
326+
.expect("Could not find $HOME!")
327+
.join("onefetch/config.toml"),
328+
),
325329
generate_config: false,
326330
}
327331
}
@@ -413,7 +417,7 @@ mod test {
413417
info: InfoCliOptions {
414418
number_of_authors: 4,
415419
no_merges: true,
416-
disabled_fields: vec![InfoType::Version, InfoType::URL],
420+
disabled_fields: vec![InfoType::Version, InfoType::URL].into(),
417421
..Default::default()
418422
},
419423
ascii: AsciiCliOptions {

src/info/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,11 @@ impl InfoBuilder {
222222
Self {
223223
title: None,
224224
info_fields: Vec::new(),
225-
// I have totally NO idea how to properly override values
226-
// if cli_options.info.disabled_fields is NOT type of Option<T>
227-
disabled_fields: cli_options.info.disabled_fields.clone(),
225+
disabled_fields: cli_options
226+
.info
227+
.disabled_fields
228+
.clone()
229+
.unwrap_or(config_options.disabled_fields.clone()),
228230
no_title: cli_options.info.no_title,
229231
}
230232
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Lib is present to allow for benchmarks and integration tests
22
pub mod cli;
3+
pub mod config;
34
pub mod info;
45
pub mod ui;
5-
pub mod config;

0 commit comments

Comments
 (0)