winbrew_app\operations/
config.rs

1use anyhow::Result;
2
3use crate::database::Config;
4pub use crate::models::domains::shared::{ConfigSection, ConfigValue, ConfigValueSource};
5
6pub fn list_sections(config: &Config) -> Result<Vec<ConfigSection>> {
7    config.effective_sections()
8}
9
10pub fn get_display_value(config: &Config, key: &str) -> Result<ConfigValue> {
11    let (value, source) = config.effective_value(key)?;
12
13    Ok(ConfigValue { value, source })
14}
15
16pub fn set_value(config: &mut Config, key: &str, value: &str) -> Result<()> {
17    config.set_value(key, value)?;
18    config.save_default()?;
19    Ok(())
20}
21
22pub fn unset_value(config: &mut Config, key: &str) -> Result<()> {
23    config.unset_value(key)?;
24    config.save_default()?;
25    Ok(())
26}