Skip to main content

tinywasm_cli/
lib.rs

1pub mod cli;
2pub mod cmd;
3pub mod engine_flags;
4pub mod load;
5pub mod output;
6#[cfg(feature = "tests")]
7pub mod testsuite;
8pub mod value_parse;
9#[cfg(feature = "wast")]
10pub mod wast_runner;
11
12use anyhow::Result;
13use clap::CommandFactory;
14
15pub use cli::{Cli, Commands};
16
17pub fn run_cli(cli: Cli) -> Result<()> {
18    match cli.command {
19        Some(Commands::Run(args)) => cmd::run::run(args),
20        Some(Commands::Compile(args)) => cmd::compile::run(args),
21        Some(Commands::Dump(args)) => cmd::dump::run(args),
22        Some(Commands::Inspect(args)) => cmd::inspect::run(args),
23        #[cfg(feature = "wast")]
24        Some(Commands::Wast(args)) => cmd::wast::run(args),
25        Some(Commands::Completion(args)) => cmd::completion::run(args),
26        None => match cli.run.module.as_deref() {
27            Some(_) => cmd::run::run(cli.run),
28            None => {
29                let mut cmd = Cli::command();
30                cmd.print_help()?;
31                println!();
32                Ok(())
33            }
34        },
35    }
36}