use assert_cmd::prelude::*; // Add methods on commands
use assert_fs::fixture::TempDir;
use predicates::prelude::*; // Used for writing assertions
use std::process::Command; // Run programs

#[test]
fn standard_cli_usage() -> Result<(), Box<dyn std::error::Error>> {
    let tmp_dir = TempDir::new().unwrap();
    let site_dir = tmp_dir.join("test_site");

    let mut cmd = Command::cargo_bin("kobold")?;
    cmd.arg("init").arg(&site_dir);

    cmd.assert()
        .success()
        .stderr(predicate::str::contains(format!(
            "Kobold website successfully initialized at `{}`",
            site_dir.display()
        )));

    let mut cmd = Command::cargo_bin("kobold")?;
    cmd.arg("build").arg(&site_dir);

    cmd.assert().success().stderr(predicate::str::contains(
        "Site generation completed successfully.",
    ));

    Ok(())
}
