@@ -40,7 +40,8 @@ pub enum FileExtension {
4040#[ command( version) ]
4141#[ command( after_help = "[1m[1m[4mNotes:[0m
4242 - If no command is provided, the [1mbuild[0m command is run by default. See `rescript help build` for more information.
43- - For the legacy (pre-v12) build system, run `rescript-legacy` instead." ) ]
43+ - To create a new ReScript project, or to add ReScript to an existing project, use https://github.com/rescript-lang/create-rescript-app.
44+ - For the legacy (pre-v12) build system, run `rescript-legacy`." ) ]
4445pub struct Cli {
4546 /// Verbosity:
4647 /// -v -> Debug
@@ -173,52 +174,50 @@ fn build_default_args(raw_args: &[OsString]) -> Vec<OsString> {
173174
174175#[ derive( Args , Debug , Clone ) ]
175176pub struct FolderArg {
176- /// The relative path to where the main rescript.json resides. IE - the root of your project .
177+ /// Path to the project or subproject. This folder must contain a rescript.json file .
177178 #[ arg( default_value = "." ) ]
178179 pub folder : String ,
179180}
180181
181182#[ derive( Args , Debug , Clone ) ]
182183pub struct FilterArg {
183- /// Filter files by regex
184- ///
185- /// Filter allows for a regex to be supplied which will filter the files to be compiled. For
186- /// instance, to filter out test files for compilation while doing feature work.
184+ /// Filter source files by regex.
185+ /// E.g., filter out test files for compilation while doing feature work.
187186 #[ arg( short, long, value_parser = parse_regex) ]
188187 pub filter : Option < Regex > ,
189188}
190189
191190#[ derive( Args , Debug , Clone ) ]
192191pub struct AfterBuildArg {
193- /// Action after build
194- ///
195- /// This allows one to pass an additional command to the watcher, which allows it to run when
196- /// finished. For instance, to play a sound when done compiling, or to run a test suite.
197- /// NOTE - You may need to add '--color=always' to your subcommand in case you want to output
198- /// color as well
192+ /// Run an additional command after build.
193+ /// E.g., play a sound or run a test suite when done compiling.
199194 #[ arg( short, long) ]
200195 pub after_build : Option < String > ,
201196}
202197
203198#[ derive( Args , Debug , Clone , Copy ) ]
204199pub struct CreateSourceDirsArg {
205- /// Create source_dirs.json
206- ///
207- /// This creates a source_dirs.json file at the root of the monorepo, which is needed when you
208- /// want to use Reanalyze
200+ /// Create a source_dirs.json file at the root of the monorepo, needed for Reanalyze.
209201 #[ arg( short, long, default_value_t = false , num_args = 0 ..=1 ) ]
210202 pub create_sourcedirs : bool ,
211203}
212204
213205#[ derive( Args , Debug , Clone , Copy ) ]
214206pub struct DevArg {
215207 /// Deprecated: Build development dependencies
216- ///
217208 /// This is the flag no longer does anything and will be removed in future versions.
218209 #[ arg( long, default_value_t = false , num_args = 0 ..=1 , hide = true ) ]
219210 pub dev : bool ,
220211}
221212
213+ #[ derive( Args , Debug , Clone ) ]
214+ pub struct WarnErrorArg {
215+ /// Override warning configuration from rescript.json.
216+ /// Example: --warn-error "+3+8+11+12+26+27+31+32+33+34+35+39+44+45+110"
217+ #[ arg( long) ]
218+ pub warn_error : Option < String > ,
219+ }
220+
222221#[ derive( Args , Debug , Clone ) ]
223222pub struct BuildArgs {
224223 #[ command( flatten) ]
@@ -236,21 +235,16 @@ pub struct BuildArgs {
236235 #[ command( flatten) ]
237236 pub dev : DevArg ,
238237
239- /// Disable timing on the output
238+ #[ command( flatten) ]
239+ pub warn_error : WarnErrorArg ,
240+
241+ /// Disable output timing
240242 #[ arg( short, long, default_value_t = false , num_args = 0 ..=1 ) ]
241243 pub no_timing : bool ,
242244
243245 /// Watch mode (deprecated, use `rescript watch` instead)
244- #[ arg( short, default_value_t = false , num_args = 0 ..=1 ) ]
246+ #[ arg( short, default_value_t = false , num_args = 0 ..=1 , hide = true ) ]
245247 pub watch : bool ,
246-
247- /// Warning numbers and whether to turn them into errors
248- ///
249- /// This flag overrides any warning configuration in rescript.json.
250- /// Example: --warn-error "+3+8+11+12+26+27+31+32+33+34+35+39+44+45+110"
251- /// This follows the same precedence behavior as the legacy bsb build system.
252- #[ arg( long) ]
253- pub warn_error : Option < String > ,
254248}
255249
256250#[ cfg( test) ]
@@ -408,13 +402,8 @@ pub struct WatchArgs {
408402 #[ command( flatten) ]
409403 pub dev : DevArg ,
410404
411- /// Warning numbers and whether to turn them into errors
412- ///
413- /// This flag overrides any warning configuration in rescript.json.
414- /// Example: --warn-error "+3+8+11+12+26+27+31+32+33+34+35+39+44+45+110"
415- /// This follows the same precedence behavior as the legacy bsb build system.
416- #[ arg( long) ]
417- pub warn_error : Option < String > ,
405+ #[ command( flatten) ]
406+ pub warn_error : WarnErrorArg ,
418407}
419408
420409impl From < BuildArgs > for WatchArgs {
@@ -444,7 +433,7 @@ pub enum Command {
444433 #[ command( flatten) ]
445434 dev : DevArg ,
446435 } ,
447- /// Formats ReScript files.
436+ /// Format ReScript files.
448437 Format {
449438 /// Check formatting status without applying changes.
450439 #[ arg( short, long) ]
@@ -467,9 +456,9 @@ pub enum Command {
467456 #[ command( flatten) ]
468457 dev : DevArg ,
469458 } ,
470- /// This prints the compiler arguments. It expects the path to a rescript file (.res or .resi) .
459+ /// Print the compiler arguments for a ReScript source file .
471460 CompilerArgs {
472- /// Path to a rescript file (.res or .resi)
461+ /// Path to a ReScript source file (.res or .resi)
473462 #[ command( ) ]
474463 path : String ,
475464 } ,
@@ -514,3 +503,11 @@ impl Deref for DevArg {
514503 & self . dev
515504 }
516505}
506+
507+ impl Deref for WarnErrorArg {
508+ type Target = Option < String > ;
509+
510+ fn deref ( & self ) -> & Self :: Target {
511+ & self . warn_error
512+ }
513+ }
0 commit comments