//! `faunosteo-worker` entry: a plain `main`, no async runtime, no thread, so the `decode` //! child installs its sandbox in a single-threaded process (review Part IV.1). //! //! Subcommands: `decode` (the sandboxed child, R0), `verify` (the sandboxed sheet verdict //! child, V1-2.3), `run` (the keyed job loop, R1), `run --jobs sheet-verify` (the verification //! loop), `run --check` (prints the resolved configuration without secrets), `version`. #[cfg(feature = "test-hooks")] use std::io::Write; use faunosteo_worker::{decode, exit_codes, verify}; fn main() { let args: Vec = std::env::args().collect(); let code = match args.get(1).map(String::as_str) { Some("decode") => { let stdin = std::io::stdin(); let stdout = std::io::stdout(); let stderr = std::io::stderr(); decode::main( &args[2..], &mut stdin.lock(), &mut stdout.lock(), &mut stderr.lock(), ) } Some("verify") => { let stdin = std::io::stdin(); let stdout = std::io::stdout(); let stderr = std::io::stderr(); verify::main( &args[2..], &mut stdin.lock(), &mut stdout.lock(), &mut stderr.lock(), ) } Some("run") => faunosteo_worker::run::main(&args[2..]), Some("version") => version(), #[cfg(feature = "test-hooks")] Some("fixture") => fixture(&args[2..]), #[cfg(feature = "test-hooks")] Some("print-allowlist") => { for name in faunosteo_worker::sandbox::allowed_names() { println!("{name}"); } exit_codes::OK } _ => { eprintln!( "usage: faunosteo-worker " ); exit_codes::USAGE } }; std::process::exit(code); } fn version() -> i32 { let (major, minor, revision) = decode::libwebp_version(); println!( "faunosteo-worker {} (core {}, libwebp {major}.{minor}.{revision})", env!("CARGO_PKG_VERSION"), faunosteo_core::CORE_VERSION ); exit_codes::OK } #[cfg(feature = "test-hooks")] fn fixture(args: &[String]) -> i32 { let Some(bytes) = args .first() .and_then(|name| faunosteo_worker::fixtures::by_name(name)) else { eprintln!( "usage: faunosteo-worker fixture " ); return exit_codes::USAGE; }; let stdout = std::io::stdout(); let mut lock = stdout.lock(); if lock.write_all(&bytes).and_then(|()| lock.flush()).is_err() { return exit_codes::OUTPUT_FAILED; } exit_codes::OK }