From 463a3a6f56a5ca06cda890fd6fe7f16485ef70a0 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 26 Apr 2026 19:44:34 +0200 Subject: feat: new tinywasm cli Signed-off-by: Henry --- crates/cli/src/lib.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 crates/cli/src/lib.rs (limited to 'crates/cli/src/lib.rs') diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs new file mode 100644 index 0000000..bef6b72 --- /dev/null +++ b/crates/cli/src/lib.rs @@ -0,0 +1,34 @@ +pub mod cli; +pub mod cmd; +pub mod engine_flags; +pub mod load; +pub mod output; +pub mod value_parse; +#[cfg(feature = "wast")] +pub mod wast_runner; + +use clap::CommandFactory; +use eyre::Result; + +pub use cli::{Cli, Commands}; + +pub fn run_cli(cli: Cli) -> Result<()> { + match cli.command { + Some(Commands::Run(args)) => cmd::run::run(args), + Some(Commands::Compile(args)) => cmd::compile::run(args), + Some(Commands::Dump(args)) => cmd::dump::run(args), + Some(Commands::Inspect(args)) => cmd::inspect::run(args), + #[cfg(feature = "wast")] + Some(Commands::Wast(args)) => cmd::wast::run(args), + Some(Commands::Completion(args)) => cmd::completion::run(args), + None => match cli.run.module.as_deref() { + Some(_) => cmd::run::run(cli.run), + None => { + let mut cmd = Cli::command(); + cmd.print_help()?; + println!(); + Ok(()) + } + }, + } +} -- cgit v1.3.1