Skip to content

Commit

Permalink
refactor: check profile activation in the lib instead of the cli
Browse files Browse the repository at this point in the history
  • Loading branch information
oknozor committed Apr 5, 2022
1 parent 0be91db commit 078fe24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/bin/bombadil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,9 @@ fn main() {
let mut bombadil =
Bombadil::from_settings(Mode::Gpg).unwrap_or_else(|err| fatal!("{}", err));

if !profiles.is_empty() {
bombadil
.enable_profiles(profiles.iter().map(String::as_str).collect())
.unwrap_or_else(|err| fatal!("{}", err));
}
bombadil
.enable_profiles(profiles.iter().map(String::as_str).collect())
.unwrap_or_else(|err| fatal!("{}", err));

bombadil.install().unwrap_or_else(|err| fatal!("{}", err));
}
Expand Down Expand Up @@ -196,11 +194,9 @@ fn main() {
}
.unwrap_or_else(|err| fatal!("{}", err));

if !profiles.is_empty() {
bombadil
.enable_profiles(profiles.iter().map(String::as_str).collect())
.unwrap_or_else(|err| fatal!("{}", err));
}
bombadil
.enable_profiles(profiles.iter().map(String::as_str).collect())
.unwrap_or_else(|err| fatal!("{}", err));

bombadil.print_metadata(metadata_type);
}
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ impl Bombadil {

/// Enable a dotfile profile by merging its config with the default profile
pub fn enable_profiles(&mut self, profile_keys: Vec<&str>) -> Result<()> {
if profile_keys.is_empty() {
return Ok(());
}

let mut profiles: Vec<Profile> = profile_keys
.iter()
// unwrap here is safe cause allowed profile keys are checked by clap
Expand Down

0 comments on commit 078fe24

Please sign in to comment.