wasm_js/command/
mod.rs

1//! CLI command structures, parsing, and execution.
2pub mod build;
3
4use crate::Cli;
5
6use self::build::{Build, BuildOptions};
7use anyhow::Result;
8use clap::Subcommand;
9use log::info;
10
11#[derive(Debug, Subcommand)]
12pub enum Command {
13    /// Compile Web Assembly and Produce Javascript
14    #[clap(name = "build")]
15    Build(BuildOptions),
16}
17
18/// Run a command with the given logger!
19pub fn run_command(args: &Cli) -> Result<()> {
20    // Run the correct command based off input and store the result of it so that we can clear
21    // the progress bar then return it
22    match &args.cmd {
23        Command::Build(build_opts) => {
24            info!("Running build command...");
25            Build::try_from_opts(&args, &build_opts).and_then(|mut b| b.run())
26        }
27    }
28}