ravenous-tools/crates/monsters/src/lib.rs

43 lines
1.5 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//! # Monsters Module
//!
//! The `monsters` crate orchestrates the processing of *ravenous* monster data.
//!
//! It can:
//! * **Parse** raw monster definitions into ergonomic Rust structs.
//! * Perform **balancing** calculations to keep encounters fair.
//! * **Show** concise, human‑readable summaries in the terminal.
//! * **Export** processed data as LaTeX/TeX for printing or further editing.
//!
//! All functionality is exposed through a single entry point:
//! [`monsters_dispatch`]. The dispatcher interprets command‑line arguments
//! (`MonsterConfig`) and delegates to the appropriate sub‑routine (clean, export or show).
//!
use crate::monster_export::generate_monsters_tex;
use config::monsters::MonsterTarget;
use anyhow::Context;
mod monster_database;
mod monster_export;
pub mod monster_structs;
use anyhow::Result;
use cli_parser::Config;
use config::monsters::MonsterConfig;
use rusqlite::Connection;
/// Dispatches the chosen monster action.
pub fn monsters_dispatch(args: &MonsterConfig, config: &Config) -> Result<()> {
// use config::monsters::MonsterTarget;
let connection =
Connection::open(&args.database).context(format!("Opening database {}", args.database))?;
match args.target {
// MonsterTarget::Clean => unimplemented!("implement cleaning logic"),
MonsterTarget::Export => generate_monsters_tex(args, config, connection)?,
// MonsterTarget::Show => unimplemented!("implement show logic"),
}
Ok(())
}