termcinema-cli 0.1.0

🎬 Animated terminal-to-SVG renderer CLI for the termcinema project
Documentation
use crate::args::CliArgs;
use crate::style::patch_theme;
use anyhow::Result;
use termcinema_engine::{
    ControlSpec, CursorSpec, StyleSpec, ThemeError, all_presets, resolve_theme,
};

/// Resolve the selected theme and apply CLI overrides.
///
/// Steps:
/// - Loads the preset theme using `--theme` (or fallback default)
/// - Applies user-specified overrides (font, speed, color, etc.)
///
/// Returns the fully configured:
/// - [`StyleSpec`]  → visual properties (font, color)
/// - [`CursorSpec`] → cursor character settings
/// - [`ControlSpec`] → animation behavior
///
/// Returns an error if the theme name is invalid.
pub(crate) fn resolve_and_patch_theme(
    args: &CliArgs,
    is_script: bool,
) -> Result<(StyleSpec, CursorSpec, ControlSpec), ThemeError> {
    // Resolve theme from name
    let (mut style, mut cursor, mut control) = resolve_theme(args.theme.as_deref())?;

    // Apply CLI-level overrides (font, speed, color, etc.)
    patch_theme(&mut style, &mut cursor, &mut control, args, is_script);

    Ok((style, cursor, control))
}

/// Print a list of all available theme presets to stdout.
///
/// Used by `--list-themes` to preview supported visual styles.
pub(crate) fn print_theme_list() {
    println!("\x1b[36m\n🎨 Built-in themes:\x1b[0m");

    for preset in all_presets() {
        let slug = preset.name.to_lowercase().replace(' ', "_");
        println!("   • {:<17} (\"{}\")", preset.name, slug);
    }

    println!("\n💡 Pass a theme using: --theme \"poke_terminal\"");

    println!();
}

/// Return the names of all built-in themes.
///
/// Useful for SDKs, GUI dropdowns, or autocomplete.
#[allow(dead_code)]
pub fn available_theme_names() -> Vec<&'static str> {
    all_presets().into_iter().map(|t| t.name).collect()
}