audb-cli 0.1.11

Command-line interface for AuDB database application framework
//! Development mode command
//!
//! Implements the `au dev` command for watching gold files and regenerating on changes.

use anyhow::Result;
use console::{Term, style};

/// Run the dev command
pub fn run(gold_dir: &str, output_dir: &str) -> Result<()> {
    let term = Term::stdout();

    term.write_line("")?;
    term.write_line(&format!(
        "{} {}",
        style("Starting development mode").bold().cyan(),
        style("(Press Ctrl+C to stop)").dim()
    ))?;
    term.write_line(&format!(
        "{} {}",
        style("Watching:").dim(),
        style(gold_dir).white()
    ))?;
    term.write_line(&format!(
        "{} {}",
        style("Output:").dim(),
        style(output_dir).white()
    ))?;
    term.write_line("")?;

    // Use the watcher to watch and regenerate
    audb_build::Watcher::new()
        .gold_dir(gold_dir)
        .output_dir(output_dir)
        .watch()?;

    Ok(())
}