anvilforge-cli 0.3.8

Smith — Anvilforge's CLI (Artisan equivalent). Scaffolding, migrations, serve, queue:work, schedule:run, test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! `anvil fmt` — wraps `cargo fmt --all`.

use anyhow::{Context, Result};
use std::process::Command;

pub fn run(check: bool) -> Result<()> {
    let mut cmd = Command::new("cargo");
    cmd.args(["fmt", "--all"]);
    if check {
        cmd.args(["--", "--check"]);
    }
    let status = cmd.status().context("failed to spawn cargo fmt")?;
    if !status.success() {
        anyhow::bail!("fmt exited with {status}");
    }
    Ok(())
}