summaryrefslogtreecommitdiff
path: root/crates/cli/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/cli/src/lib.rs')
-rw-r--r--crates/cli/src/lib.rs34
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(())
+ }
+ },
+ }
+}