Skip to main content

codetether_agent/cli/
config.rs

1//! Configuration management commands
2
3use super::ConfigArgs;
4use crate::config::Config;
5use anyhow::Result;
6
7pub async fn execute(args: ConfigArgs) -> Result<()> {
8    if args.show {
9        let config = Config::load().await?;
10        println!("{}", toml::to_string_pretty(&config)?);
11        return Ok(());
12    }
13
14    if args.init {
15        Config::init_default().await?;
16        println!("Configuration initialized");
17        return Ok(());
18    }
19
20    if let Some(kv) = args.set {
21        let parts: Vec<&str> = kv.splitn(2, '=').collect();
22        if parts.len() != 2 {
23            anyhow::bail!("Invalid format. Use: --set key=value");
24        }
25        Config::set(parts[0], parts[1]).await?;
26        println!("Set {} = {}", parts[0], parts[1]);
27        return Ok(());
28    }
29
30    // Default: show help
31    println!("Use --show, --init, or --set key=value");
32    Ok(())
33}