Skip to main content

crates_docs/cli/
config_cmd.rs

1//! Config command implementation
2
3use std::path::PathBuf;
4
5/// Generate configuration file command
6pub fn run_config_command(output: &PathBuf, force: bool) -> Result<(), Box<dyn std::error::Error>> {
7    if output.exists() && !force {
8        return Err(format!(
9            "Config file already exists: {}, use --force to overwrite",
10            output.display()
11        )
12        .into());
13    }
14
15    let config = crate::config::AppConfig::default();
16    config
17        .save_to_file(output)
18        .map_err(|e| format!("Failed to save config file: {e}"))?;
19
20    println!("Config file generated: {}", output.display());
21    println!("Please edit the config file as needed.");
22
23    Ok(())
24}