lichenn 1.1.1

Manage and generate the licenses of your project effectively and mighty quick, with a smooth interface, custom rules and configuration
Documentation
//! # Initialize Command
//!
//! Logic for the `lichen init` command (currently placeholder).

use crate::error::LichenError;
use crate::models::InitArgs;
use log::debug;
use std::fs;

/// Handles the `init` command logic (currently a placeholder).
pub fn handle_init(args: InitArgs) -> Result<(), LichenError> {
    debug!("Starting handle_init with args: {:?}", args);

    let project_root = match args.target {
        Some(p) => {
            debug!("Using specified path for initialization: '{}'", p.display());
            p
        }
        None => {
            let cwd = std::env::current_dir()?;
            debug!(
                "No path specified, using current working directory: '{}'",
                cwd.display()
            );
            cwd
        }
    };

    debug!(
        "Initializing default configuration in: '{}'",
        project_root.display()
    );

    fs::write(
        ".lichen.toml",
        include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/default.toml")),
    )?;

    Ok(())
}