@@ -15,6 +15,10 @@ enum Command {
15
15
Watch ,
16
16
/// Clean the build artifacts
17
17
Clean ,
18
+ /// Format the code
19
+ Format ,
20
+ /// Dump
21
+ Dump ,
18
22
}
19
23
20
24
/// Rewatch is an alternative build system for the Rescript Compiler bsb (which uses Ninja internally). It strives
@@ -23,11 +27,12 @@ enum Command {
23
27
#[ derive( Parser , Debug ) ]
24
28
#[ command( version) ]
25
29
struct Args {
26
- #[ arg( value_enum) ]
27
- command : Option < Command > ,
30
+ #[ arg( value_enum, default_value_t = Command :: Build ) ]
31
+ command : Command ,
28
32
29
33
/// The relative path to where the main rescript.json resides. IE - the root of your project.
30
- folder : Option < String > ,
34
+ #[ arg( default_value = "." ) ]
35
+ folder : String ,
31
36
32
37
/// Filter allows for a regex to be supplied which will filter the files to be compiled. For
33
38
/// instance, to filter out test files for compilation while doing feature work.
@@ -79,10 +84,22 @@ struct Args {
79
84
/// A custom path to bsc
80
85
#[ arg( long) ]
81
86
bsc_path : Option < String > ,
87
+
88
+ /// Use the legacy build system.
89
+ ///
90
+ /// After this flag is encountered, the rest of the command line arguments are passed to the legacy build system.
91
+ #[ arg( long, allow_hyphen_values = true , num_args = 0 ..) ]
92
+ legacy : Option < Vec < String > > ,
82
93
}
83
94
84
95
fn main ( ) -> Result < ( ) > {
85
96
let args = Args :: parse ( ) ;
97
+
98
+ if let Some ( legacy_args) = args. legacy {
99
+ let code = build:: pass_through_legacy ( legacy_args) ;
100
+ std:: process:: exit ( code) ;
101
+ }
102
+
86
103
let log_level_filter = args. verbose . log_level_filter ( ) ;
87
104
88
105
env_logger:: Builder :: new ( )
@@ -91,8 +108,6 @@ fn main() -> Result<()> {
91
108
. target ( env_logger:: fmt:: Target :: Stdout )
92
109
. init ( ) ;
93
110
94
- let command = args. command . unwrap_or ( Command :: Build ) ;
95
- let folder = args. folder . unwrap_or ( "." . to_string ( ) ) ;
96
111
let filter = args
97
112
. filter
98
113
. map ( |filter| Regex :: new ( filter. as_ref ( ) ) . expect ( "Could not parse regex" ) ) ;
@@ -112,17 +127,17 @@ fn main() -> Result<()> {
112
127
// level, we should never show that.
113
128
let show_progress = log_level_filter == LevelFilter :: Info ;
114
129
115
- match lock:: get ( & folder) {
130
+ match lock:: get ( & args . folder ) {
116
131
lock:: Lock :: Error ( ref e) => {
117
132
println ! ( "Could not start Rewatch: {e}" ) ;
118
133
std:: process:: exit ( 1 )
119
134
}
120
- lock:: Lock :: Aquired ( _) => match command {
121
- Command :: Clean => build:: clean:: clean ( & folder, show_progress, args. bsc_path , args. dev ) ,
135
+ lock:: Lock :: Aquired ( _) => match args . command {
136
+ Command :: Clean => build:: clean:: clean ( & args . folder , show_progress, args. bsc_path , args. dev ) ,
122
137
Command :: Build => {
123
138
match build:: build (
124
139
& filter,
125
- & folder,
140
+ & args . folder ,
126
141
show_progress,
127
142
args. no_timing ,
128
143
args. create_sourcedirs ,
@@ -145,7 +160,7 @@ fn main() -> Result<()> {
145
160
watcher:: start (
146
161
& filter,
147
162
show_progress,
148
- & folder,
163
+ & args . folder ,
149
164
args. after_build ,
150
165
args. create_sourcedirs ,
151
166
args. dev ,
@@ -154,6 +169,12 @@ fn main() -> Result<()> {
154
169
155
170
Ok ( ( ) )
156
171
}
172
+ Command :: Format => {
173
+ todo ! ( "Format not implemented yet" ) ;
174
+ }
175
+ Command :: Dump => {
176
+ todo ! ( "Dump not implemented yet" ) ;
177
+ }
157
178
} ,
158
179
}
159
180
}
0 commit comments