gitprofile/commands/
apply.rs1use crate::{
2 context::AppContext,
3 git::{Level}
4};
5use anyhow::{anyhow, Result};
6
7pub fn execute(context: &AppContext, profile_key: &str, maybe_level: &Option<Level>) -> Result<()> {
8 let config = context.config_client.load()?;
9 let git_config_client = context.git_config_client.as_ref();
10
11 if let Some(profile) = config.profile.get(profile_key) {
12 git_config_client.set(&profile, &maybe_level)?;
13 println!("✨ Successfully applied {}", profile_key);
14 Ok(())
15 } else {
16 Err(anyhow!("Profile {} doesn't exist", profile_key))
17 }
18}