feat(cli): add --cell-size flag, route png through build_png

This commit is contained in:
2026-03-23 02:47:58 +01:00
parent 87d49f8959
commit 4842000c31
2 changed files with 17 additions and 4 deletions

View File

@@ -65,6 +65,10 @@ struct Cli {
/// Width in blocks inserted for a space character
#[arg(long, default_value_t = 4)]
word_spacing: u32,
/// Cell size in pixels for PNG export (8-64)
#[arg(long, default_value_t = 16, value_parser = clap::value_parser!(u32).range(8..=64))]
cell_size: u32,
}
fn palettes_dir() -> PathBuf {
@@ -160,12 +164,20 @@ pub fn run() -> anyhow::Result<()> {
.filter(|&name| seen.insert(name))
.collect();
// Build and validate in one pass
// Build and validate in one pass; route "png" through build_png to honour --cell-size
let exporters_to_run = format_names
.iter()
.map(|&name| -> anyhow::Result<_> {
exporters::build(name, &palette)
.ok_or_else(|| anyhow::anyhow!("unknown format '{}'. Available: {}", name, all_names.join(", ")))
.map(|&name| -> anyhow::Result<Box<dyn lib::StructureExporter>> {
if name == "png" {
Ok(exporters::build_png(&palette, cli.cell_size))
} else {
exporters::build(name, &palette)
.ok_or_else(|| anyhow::anyhow!(
"unknown format '{}'. Available: {}",
name,
all_names.join(", ")
))
}
})
.collect::<anyhow::Result<Vec<_>>>()?;