diff options
| author | Henry <mail@henrygressmann.de> | 2026-04-26 19:44:34 +0200 |
|---|---|---|
| committer | Henry <mail@henrygressmann.de> | 2026-04-26 19:44:34 +0200 |
| commit | 463a3a6f56a5ca06cda890fd6fe7f16485ef70a0 (patch) | |
| tree | bfa657a2de16c04cd36f4b6c61e77b370fcd46fc /crates/cli/src/lib.rs | |
| parent | 27004a8738c7a3c32ac4fb6966f32647b4c96db7 (diff) | |
feat: new tinywasm cli
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates/cli/src/lib.rs')
| -rw-r--r-- | crates/cli/src/lib.rs | 34 |
1 files changed, 34 insertions, 0 deletions
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(()) + } + }, + } +} |
