-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.rs
53 lines (41 loc) · 1.33 KB
/
cli.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(about)]
pub struct Options {
/// Logging verbosity (-v info, -vv debug, -vvv trace)
#[structopt(short = "v", long = "verbose", parse(from_occurrences), global = true)]
pub verbose: u8,
/// Input file ("-" means stdin)
#[structopt(default_value = "-")]
pub input: String,
/// Output file ("-" means stdout)
#[structopt(short = "o", default_value = "-")]
pub output: String,
/// Minify when emitting JS
#[structopt(short = "M", long = "minify")]
pub minify: bool,
/// Run optimizations (implies all --opt-* flags)
#[structopt(short = "O", long = "optimize")]
pub optimize: bool,
/// Run optimization passes on IR
#[structopt(long = "opt-ir")]
pub opt_ir: bool,
/// Inline SSA values when emitting JS
#[structopt(long = "opt-inline-ssa")]
pub opt_inline_ssa: bool,
/// Run optimization passes on AST
#[structopt(long = "opt-ast")]
pub opt_ast: bool,
/// Output IR instead of JS
#[structopt(long = "emit-ir")]
pub emit_ir: bool,
}
impl Options {
pub fn from_args() -> Self {
let mut this: Self = StructOpt::from_args();
this.opt_ir |= this.optimize;
this.opt_inline_ssa |= this.optimize;
this.opt_ast |= this.optimize;
this
}
}