@@ -2,6 +2,11 @@ use std::{ffi::OsString, ops::Deref};
2
2
3
3
use clap:: { Args , Parser , Subcommand } ;
4
4
use clap_verbosity_flag:: InfoLevel ;
5
+ use regex:: Regex ;
6
+
7
+ fn parse_regex ( s : & str ) -> Result < Regex , regex:: Error > {
8
+ Regex :: new ( s)
9
+ }
5
10
6
11
/// ReScript - Fast, Simple, Fully Typed JavaScript from the Future
7
12
#[ derive( Parser , Debug ) ]
@@ -39,8 +44,8 @@ pub struct FilterArg {
39
44
///
40
45
/// Filter allows for a regex to be supplied which will filter the files to be compiled. For
41
46
/// instance, to filter out test files for compilation while doing feature work.
42
- #[ arg( short, long) ]
43
- pub filter : Option < String > ,
47
+ #[ arg( short, long, value_parser = parse_regex ) ]
48
+ pub filter : Option < Regex > ,
44
49
}
45
50
46
51
#[ derive( Args , Debug , Clone ) ]
@@ -107,6 +112,10 @@ pub struct BuildArgs {
107
112
108
113
#[ command( flatten) ]
109
114
pub snapshot_output : SnapshotOutputArg ,
115
+
116
+ /// Watch mode (deprecated, use `rescript watch` instead)
117
+ #[ arg( short, default_value_t = false , num_args = 0 ..=1 ) ]
118
+ pub watch : bool ,
110
119
}
111
120
112
121
#[ derive( Args , Clone , Debug ) ]
@@ -130,6 +139,19 @@ pub struct WatchArgs {
130
139
pub snapshot_output : SnapshotOutputArg ,
131
140
}
132
141
142
+ impl From < BuildArgs > for WatchArgs {
143
+ fn from ( build_args : BuildArgs ) -> Self {
144
+ Self {
145
+ folder : build_args. folder ,
146
+ filter : build_args. filter ,
147
+ after_build : build_args. after_build ,
148
+ create_sourcedirs : build_args. create_sourcedirs ,
149
+ dev : build_args. dev ,
150
+ snapshot_output : build_args. snapshot_output ,
151
+ }
152
+ }
153
+ }
154
+
133
155
#[ derive( Subcommand , Clone , Debug ) ]
134
156
pub enum Command {
135
157
/// Build the project
@@ -187,7 +209,7 @@ impl Deref for FolderArg {
187
209
}
188
210
189
211
impl Deref for FilterArg {
190
- type Target = Option < String > ;
212
+ type Target = Option < Regex > ;
191
213
192
214
fn deref ( & self ) -> & Self :: Target {
193
215
& self . filter
0 commit comments