Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/gunnar-ui

crates/gunnar-ui-build-thing/src/main.rs

//! `gunnar-ui-build-thing` — the emission doors.
//!
//! ```text
//! gunnar-ui-build-thing emit [root]   REGENERATE .nornir/build-variants.toml from the code
//! gunnar-ui-build-thing toml          the emission, on stdout
//! gunnar-ui-build-thing --list        every declared variant and what it builds
//! ```
//!
//! No build knowledge lives here: every answer is `GunnarUiBuildThing`'s.

use std::path::PathBuf;
use std::process::ExitCode;

fn main() -> ExitCode {
    let args: Vec<String> = std::env::args().skip(1).collect();
    match args.first().map(String::as_str) {
        Some("emit") => {
            let root = args
                .get(1)
                .map(PathBuf::from)
                .unwrap_or_else(gunnar_ui_build_thing::repo_root);
            match gunnar_ui_build_thing::write_emitted(&root) {
                Ok(p) => {
                    println!("emitted {}", p.display());
                    ExitCode::SUCCESS
                }
                Err(e) => fail(&e),
            }
        }
        Some("toml") => match gunnar_ui_build_thing::emitted_toml() {
            Ok(t) => {
                print!("{t}");
                ExitCode::SUCCESS
            }
            Err(e) => fail(&e),
        },
        Some("--list") => {
            for v in gunnar_ui_build_thing::declared().variants {
                println!("{:<26} {}", v.name, v.command_line());
            }
            ExitCode::SUCCESS
        }
        _ => {
            eprintln!(
                "usage: gunnar-ui-build-thing emit [root]   regenerate .nornir/build-variants.toml from the code
       gunnar-ui-build-thing toml          the emission, on stdout
       gunnar-ui-build-thing --list        every declared variant

The declaration is `GunnarUiBuildThing::variants` (crates/gunnar-ui-recipe/src); the toml is
EMITTED from it (code -> toml, one-directional) and never read back as authority."
            );
            ExitCode::FAILURE
        }
    }
}

fn fail(e: &anyhow::Error) -> ExitCode {
    eprintln!("gunnar-ui-build-thing: {e:#}");
    ExitCode::FAILURE
}