wasm_js/
lib.rs

1extern crate anyhow;
2extern crate cargo_metadata;
3extern crate console;
4extern crate glob;
5extern crate parking_lot;
6extern crate serde;
7extern crate strsim;
8extern crate which;
9#[macro_use]
10extern crate serde_derive;
11extern crate binary_install;
12extern crate dialoguer;
13extern crate log;
14extern crate serde_ignored;
15extern crate serde_json;
16extern crate toml;
17extern crate walkdir;
18
19pub mod bindgen;
20pub mod build;
21pub mod child;
22pub mod command;
23pub mod install;
24pub mod js_bin;
25pub mod lockfile;
26pub mod manifest;
27pub mod progressbar;
28pub mod stamps;
29pub mod target;
30pub mod test;
31pub mod utils;
32pub mod wasm_opt;
33
34use crate::progressbar::{LogLevel, ProgressOutput};
35use clap::builder::ArgAction;
36use clap::Parser;
37
38/// The global progress bar and user-facing message output.
39pub static PBAR: ProgressOutput = ProgressOutput::new();
40
41#[derive(Debug, Parser)]
42#[command(version)]
43pub struct Cli {
44    /// The subcommand to run.
45    #[clap(subcommand)] // Note that we mark a field as a subcommand
46    pub cmd: command::Command,
47
48    /// Log verbosity is based off the number of v used
49    #[clap(long = "verbose", short = 'v', action = ArgAction::Count)]
50    pub verbosity: u8,
51
52    #[clap(long = "quiet", short = 'q')]
53    /// No output printed to stdout
54    pub quiet: bool,
55
56    #[clap(long = "log-level", default_value = "info")]
57    /// The maximum level of messages that should be logged by
58    pub log_level: LogLevel,
59
60    #[clap(long = "install-cache")]
61    /// Sets the location of the binary install cache
62    pub install_cache: Option<String>,
63}
64
65impl Cli {
66    pub fn from_command(cmd: command::Command) -> Self {
67        Self {
68            cmd,
69            verbosity: 0,
70            quiet: false,
71            log_level: LogLevel::Info,
72            install_cache: None,
73        }
74    }
75}