swc_cli_impl/commands/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use clap::{Parser, Subcommand};

mod bundle;
mod compile;
mod lint;
mod minify;
mod plugin;

pub use bundle::*;
pub use compile::*;
pub use lint::*;
pub use minify::*;
pub use plugin::PluginSubcommand;

// Set of subcommands supported by the `swc` command.
#[derive(Subcommand)]
pub enum Command {
    /// Commandline utilities for creating, building plugins.
    #[clap(subcommand)]
    Plugin(PluginSubcommand),
    /// Run SWC's transformer.
    Compile(Box<CompileOptions>),
    Bundle(BundleOptions),
    Minify(MinifyOptions),
    Lint(LintOptions),
}

#[derive(Parser)]
#[clap(name = "SWC", version, propagate_version = true)]
pub struct SwcCliOptions {
    #[clap(subcommand)]
    pub command: Command,
}

pub trait CommandRunner {
    fn execute(&self) -> anyhow::Result<()>;
}