Files
xop/src/main.rs
T
2026-10-02 18:25:29 +08:00

31 lines
997 B
Rust

//! xop CLI entry point.
//!
//! See `lib.rs` for the orchestrator and `args.rs` for the full CLI surface.
use clap::Parser;
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
use xop::{run, Args};
fn main() -> anyhow::Result<()> {
// Logging: respect RUST_LOG, default to "xop=info,warn".
tracing_subscriber::registry()
.with(EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("xop=info,warn")))
.with(fmt::layer().with_target(false).without_time())
.init();
let args = Args::parse();
// Run the orchestrator on a tokio runtime.
let rt = tokio::runtime::Runtime::new()
.map_err(|e| anyhow::anyhow!("tokio runtime: {e}"))?;
// Propagate child exit code per spec. EX_USAGE etc. come from typed XopError.
match rt.block_on(run(args)) {
Ok(exit_code) => std::process::exit(exit_code),
Err(e) => {
eprintln!("xop: {e:#}");
std::process::exit(e.exit_code());
}
}
}