From 06cb2905cf651bcd71948fe993dd82cb65c972ee Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 19 Oct 2025 09:48:20 +0200 Subject: [PATCH 1/2] Streamline rewatch help texts --- rewatch/src/cli.rs | 71 ++++++++++++++++++++++----------------------- rewatch/src/main.rs | 6 ++-- 2 files changed, 37 insertions(+), 40 deletions(-) diff --git a/rewatch/src/cli.rs b/rewatch/src/cli.rs index 0e95dad98d..3b4604ce54 100644 --- a/rewatch/src/cli.rs +++ b/rewatch/src/cli.rs @@ -40,7 +40,8 @@ pub enum FileExtension { #[command(version)] #[command(after_help = "Notes: - If no command is provided, the build command is run by default. See `rescript help build` for more information. - - For the legacy (pre-v12) build system, run `rescript-legacy` instead.")] + - To create a new ReScript project, or to add ReScript to an existing project, use https://github.com/rescript-lang/create-rescript-app. + - For the legacy (pre-v12) build system, run `rescript-legacy`.")] pub struct Cli { /// Verbosity: /// -v -> Debug @@ -173,39 +174,30 @@ fn build_default_args(raw_args: &[OsString]) -> Vec { #[derive(Args, Debug, Clone)] pub struct FolderArg { - /// The relative path to where the main rescript.json resides. IE - the root of your project. + /// Path to the project or subproject. This folder must contain a rescript.json file. #[arg(default_value = ".")] pub folder: String, } #[derive(Args, Debug, Clone)] pub struct FilterArg { - /// Filter files by regex - /// - /// Filter allows for a regex to be supplied which will filter the files to be compiled. For - /// instance, to filter out test files for compilation while doing feature work. + /// Filter source files by regex. + /// E.g., filter out test files for compilation while doing feature work. #[arg(short, long, value_parser = parse_regex)] pub filter: Option, } #[derive(Args, Debug, Clone)] pub struct AfterBuildArg { - /// Action after build - /// - /// This allows one to pass an additional command to the watcher, which allows it to run when - /// finished. For instance, to play a sound when done compiling, or to run a test suite. - /// NOTE - You may need to add '--color=always' to your subcommand in case you want to output - /// color as well + /// Run an additional command after build. + /// E.g., play a sound or run a test suite when done compiling. #[arg(short, long)] pub after_build: Option, } #[derive(Args, Debug, Clone, Copy)] pub struct CreateSourceDirsArg { - /// Create source_dirs.json - /// - /// This creates a source_dirs.json file at the root of the monorepo, which is needed when you - /// want to use Reanalyze + /// Create a source_dirs.json file at the root of the monorepo, needed for Reanalyze. #[arg(short, long, default_value_t = false, num_args = 0..=1)] pub create_sourcedirs: bool, } @@ -213,12 +205,19 @@ pub struct CreateSourceDirsArg { #[derive(Args, Debug, Clone, Copy)] pub struct DevArg { /// Deprecated: Build development dependencies - /// /// This is the flag no longer does anything and will be removed in future versions. #[arg(long, default_value_t = false, num_args = 0..=1, hide = true)] pub dev: bool, } +#[derive(Args, Debug, Clone)] +pub struct WarnErrorArg { + /// Override warning configuration from rescript.json. + /// Example: --warn-error "+3+8+11+12+26+27+31+32+33+34+35+39+44+45+110" + #[arg(long)] + pub warn_error: Option, +} + #[derive(Args, Debug, Clone)] pub struct BuildArgs { #[command(flatten)] @@ -236,21 +235,16 @@ pub struct BuildArgs { #[command(flatten)] pub dev: DevArg, - /// Disable timing on the output + #[command(flatten)] + pub warn_error: WarnErrorArg, + + /// Disable output timing #[arg(short, long, default_value_t = false, num_args = 0..=1)] pub no_timing: bool, /// Watch mode (deprecated, use `rescript watch` instead) - #[arg(short, default_value_t = false, num_args = 0..=1)] + #[arg(short, default_value_t = false, num_args = 0..=1, hide = true)] pub watch: bool, - - /// Warning numbers and whether to turn them into errors - /// - /// This flag overrides any warning configuration in rescript.json. - /// Example: --warn-error "+3+8+11+12+26+27+31+32+33+34+35+39+44+45+110" - /// This follows the same precedence behavior as the legacy bsb build system. - #[arg(long)] - pub warn_error: Option, } #[cfg(test)] @@ -408,13 +402,8 @@ pub struct WatchArgs { #[command(flatten)] pub dev: DevArg, - /// Warning numbers and whether to turn them into errors - /// - /// This flag overrides any warning configuration in rescript.json. - /// Example: --warn-error "+3+8+11+12+26+27+31+32+33+34+35+39+44+45+110" - /// This follows the same precedence behavior as the legacy bsb build system. - #[arg(long)] - pub warn_error: Option, + #[command(flatten)] + pub warn_error: WarnErrorArg, } impl From for WatchArgs { @@ -444,7 +433,7 @@ pub enum Command { #[command(flatten)] dev: DevArg, }, - /// Formats ReScript files. + /// Format ReScript files. Format { /// Check formatting status without applying changes. #[arg(short, long)] @@ -467,9 +456,9 @@ pub enum Command { #[command(flatten)] dev: DevArg, }, - /// This prints the compiler arguments. It expects the path to a rescript file (.res or .resi). + /// Print the compiler arguments for a ReScript source file. CompilerArgs { - /// Path to a rescript file (.res or .resi) + /// Path to a ReScript source file (.res or .resi) #[command()] path: String, }, @@ -514,3 +503,11 @@ impl Deref for DevArg { &self.dev } } + +impl Deref for WarnErrorArg { + type Target = Option; + + fn deref(&self) -> &Self::Target { + &self.warn_error + } +} diff --git a/rewatch/src/main.rs b/rewatch/src/main.rs index 01eb750599..ba74dbd393 100644 --- a/rewatch/src/main.rs +++ b/rewatch/src/main.rs @@ -53,7 +53,7 @@ fn main() -> Result<()> { build_args.no_timing, *build_args.create_sourcedirs, plain_output, - build_args.warn_error.clone(), + (*build_args.warn_error).clone(), ) { Err(e) => { println!("{e}"); @@ -70,7 +70,7 @@ fn main() -> Result<()> { cli::Command::Watch(watch_args) => { let _lock = get_lock(&watch_args.folder); - if watch_args.dev.dev { + if *watch_args.dev { log::warn!( "`--dev no longer has any effect. Please remove it from your command. It will be removed in a future version." ); @@ -83,7 +83,7 @@ fn main() -> Result<()> { (*watch_args.after_build).clone(), *watch_args.create_sourcedirs, plain_output, - watch_args.warn_error.clone(), + (*watch_args.warn_error).clone(), ); Ok(()) From c2f55cc96b0d0311586884db4cc35dd6d550df50 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 19 Oct 2025 10:47:23 +0200 Subject: [PATCH 2/2] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 322688fd29..b8657b0c4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ #### :nail_care: Polish - Rewatch: plain output when not running in tty. https://github.com/rescript-lang/rescript/pull/7970 +- Streamline rewatch help texts. https://github.com/rescript-lang/rescript/pull/7973 #### :house: Internal