Skip to content

Commit 28c26b1

Browse files
committed
Add support for "rescript -w" for compatibility
1 parent 6943971 commit 28c26b1

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

rewatch/src/cli.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ pub struct BuildArgs {
107107

108108
#[command(flatten)]
109109
pub snapshot_output: SnapshotOutputArg,
110+
111+
/// Watch mode (deprecated, use `rescript watch` instead)
112+
#[arg(short, long, default_value_t = false, num_args = 0..=1)]
113+
pub watch: bool,
110114
}
111115

112116
#[derive(Args, Clone, Debug)]
@@ -130,6 +134,19 @@ pub struct WatchArgs {
130134
pub snapshot_output: SnapshotOutputArg,
131135
}
132136

137+
impl From<BuildArgs> for WatchArgs {
138+
fn from(build_args: BuildArgs) -> Self {
139+
Self {
140+
folder: build_args.folder,
141+
filter: build_args.filter,
142+
after_build: build_args.after_build,
143+
create_sourcedirs: build_args.create_sourcedirs,
144+
dev: build_args.dev,
145+
snapshot_output: build_args.snapshot_output,
146+
}
147+
}
148+
}
149+
133150
#[derive(Subcommand, Clone, Debug)]
134151
pub enum Command {
135152
/// Build the project

rewatch/src/main.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@ fn main() -> Result<()> {
1717
.target(env_logger::fmt::Target::Stdout)
1818
.init();
1919

20-
let command = args.command.unwrap_or(cli::Command::Build(args.build_args));
20+
let mut command = args.command.unwrap_or(cli::Command::Build(args.build_args));
21+
22+
if let cli::Command::Build(build_args) = &command {
23+
if build_args.watch {
24+
log::warn!("`rescript build --watch` is deprecated. Please use `rescript watch` instead.");
25+
command = cli::Command::Watch(build_args.clone().into());
26+
}
27+
}
2128

2229
// The 'normal run' mode will show the 'pretty' formatted progress. But if we turn off the log
2330
// level, we should never show that.
2431
let show_progress = log_level_filter == LevelFilter::Info;
2532

26-
match command.clone() {
33+
match command {
2734
cli::Command::CompilerArgs { path, dev } => {
2835
println!("{}", build::get_compiler_args(Path::new(&path), *dev)?);
2936
std::process::exit(0);

0 commit comments

Comments
 (0)