Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
71 changes: 34 additions & 37 deletions rewatch/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -173,52 +174,50 @@ fn build_default_args(raw_args: &[OsString]) -> Vec<OsString> {

#[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<Regex>,
}

#[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<String>,
}

#[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,
}

#[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<String>,
}

#[derive(Args, Debug, Clone)]
pub struct BuildArgs {
#[command(flatten)]
Expand All @@ -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<String>,
}

#[cfg(test)]
Expand Down Expand Up @@ -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<String>,
#[command(flatten)]
pub warn_error: WarnErrorArg,
}

impl From<BuildArgs> for WatchArgs {
Expand Down Expand Up @@ -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)]
Expand All @@ -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,
},
Expand Down Expand Up @@ -514,3 +503,11 @@ impl Deref for DevArg {
&self.dev
}
}

impl Deref for WarnErrorArg {
type Target = Option<String>;

fn deref(&self) -> &Self::Target {
&self.warn_error
}
}
6 changes: 3 additions & 3 deletions rewatch/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand All @@ -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."
);
Expand All @@ -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(())
Expand Down
Loading