From 791e3a6c6d86e1759d9efd49fe98f7f31731ff00 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 4 Sep 2026 16:59:47 -0500 Subject: [PATCH] feat: add main cli method --- src/main.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index e7a11a9..e406df1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,23 @@ -fn main() { - println!("Hello, world!"); +use std::process; + +use onx::{parse_cli_from, render_cli_error, run}; + +#[tokio::main] +async fn main() { + let cli = match parse_cli_from(std::env::args_os()) { + Ok(cli) => cli, + Err(err) => { + if err.code == 0 { + print!("{}", err.message); + process::exit(0); + } + eprintln!("{}", render_cli_error(&err, false)); + process::exit(err.code) + } + }; + + if let Err(err) = run(cli).await { + eprintln!("{}", render_cli_error(&err, false)); + process::exit(err.code) + } }