use crate::Settings;
use anyhow::{Result, bail};
use larian_formats::{format::Write, lspk::write::Writer};
use std::path::PathBuf;

impl Settings {
    pub(crate) fn pack_helper(mod_files_root: PathBuf) -> Result<()> {
        let mods_dir = mod_files_root.join("Mods");

        if !mods_dir.exists() {
            bail!("missing `Mods` directory under mod root {}", mod_files_root.display());
        }

        let writer = Writer::with_mod_root_path(mod_files_root)?;

        writer.write()?;
        Ok(())
    }
}
