Skip to content

Commit

Permalink
feat(swc/cli): setup packages for binary
Browse files Browse the repository at this point in the history
- relates with swc-project#1589
  • Loading branch information
kwonoj committed Dec 19, 2021
1 parent 967f30d commit 4825e2f
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 1 deletion.
113 changes: 112 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"crates/jsdoc",
"crates/node",
"crates/swc_cli",
"crates/swc_css",
"crates/swc_ecmascript",
"crates/swc_ecma_plugin_ast",
Expand Down
16 changes: 16 additions & 0 deletions crates/swc_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
description = "Commandline for swc"
name = "swc_cli"
version = "0.1.0"
edition = "2018"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
repository = "https://github.com/swc-project/swc.git"

[[bin]]
name = "swc"
path = "./src/main.rs"

[dependencies]
structopt = { version = "0.3.25", features = [ "paw" ] }
paw = "1.0"
37 changes: 37 additions & 0 deletions crates/swc_cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::path::PathBuf;

use structopt::StructOpt;

/// Transform, compile files.
#[derive(Debug, StructOpt)]
struct CompileCommand {
///Filename to use when reading from stdin - this will be used in
/// source-maps, errors etc
#[structopt(short = "f", long = "filename")]
file_name: String,
/// Path to a .swcrc file to use
#[structopt(parse(from_os_str), long = "config-file")]
config_file: PathBuf,
/// The name of the 'env' to use when loading configs and plugins.
/// Defaults to the value of SWC_ENV, or else NODE_ENV, or else
/// 'development'.
///
/// DEPRECATED: use --env flag instead.
#[structopt(long = "env-name")]
env_name: String,
}

#[derive(StructOpt, Debug)]
#[structopt(about = "Speedy Web Compiler")]
pub enum SwcCommand {
Compile(CompileCommand),
}

impl SwcCommand {
pub fn execute(self) {
match self {
Self::Compile => {}
};
Ok(())
}
}
6 changes: 6 additions & 0 deletions crates/swc_cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use cli::SwcCommand;

#[paw::main]
fn main(_args: SwcCommand) {
unimplemented!("Not yet implemented");
}

0 comments on commit 4825e2f

Please sign in to comment.