Skip to content

Commit eb025ad

Browse files
committed
refactor: check profile activation in the lib instead of the cli
1 parent 7076663 commit eb025ad

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/bin/bombadil.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,9 @@ fn main() {
131131
let mut bombadil =
132132
Bombadil::from_settings(Mode::Gpg).unwrap_or_else(|err| fatal!("{}", err));
133133

134-
if !profiles.is_empty() {
135-
bombadil
136-
.enable_profiles(profiles.iter().map(String::as_str).collect())
137-
.unwrap_or_else(|err| fatal!("{}", err));
138-
}
134+
bombadil
135+
.enable_profiles(profiles.iter().map(String::as_str).collect())
136+
.unwrap_or_else(|err| fatal!("{}", err));
139137

140138
bombadil.install().unwrap_or_else(|err| fatal!("{}", err));
141139
}
@@ -196,11 +194,9 @@ fn main() {
196194
}
197195
.unwrap_or_else(|err| fatal!("{}", err));
198196

199-
if !profiles.is_empty() {
200-
bombadil
201-
.enable_profiles(profiles.iter().map(String::as_str).collect())
202-
.unwrap_or_else(|err| fatal!("{}", err));
203-
}
197+
bombadil
198+
.enable_profiles(profiles.iter().map(String::as_str).collect())
199+
.unwrap_or_else(|err| fatal!("{}", err));
204200

205201
bombadil.print_metadata(metadata_type);
206202
}

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ impl Bombadil {
233233

234234
/// Enable a dotfile profile by merging its config with the default profile
235235
pub fn enable_profiles(&mut self, profile_keys: Vec<&str>) -> Result<()> {
236+
if profile_keys.is_empty() {
237+
return Ok(());
238+
}
239+
236240
let mut profiles: Vec<Profile> = profile_keys
237241
.iter()
238242
// unwrap here is safe cause allowed profile keys are checked by clap

0 commit comments

Comments
 (0)