Skip to content

Rewatch cli refactor #7551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Rewatch cli refactor #7551

wants to merge 3 commits into from

Conversation

Bushuo
Copy link
Collaborator

@Bushuo Bushuo commented Jun 15, 2025

Upstream the changes of rescript-lang/rewatch#162 and adjusted the PR description.

This PR refactors the CLI structure of rewatch to enhance clarity and improve the usability of subcommands and their associated arguments.

Key Changes:

Introduction of New Subcommands:

  • legacy: Acts as a passthrough to the legacy CLI rescript. In the future, this will be named rescript-legacy.
  • dump: Serves as an alias for legacy dump.
  • format: Serves as an alias for legacy format.

Breaking Change:

  • The --compiler-args argument has been replaced with a new subcommand compiler-args. I assume this change will have minimal impact. I guess this is mainly used as a debug command.
  • Arguments must be used after the sub-command. A call like this is invalid now rewatch --bsc-path=something build. This change was made because the number of arguments on the top level was getting out of hand and hard to track.

Benefits:
The refactored structure ensures a more intuitive CLI experience by clearly delineating which arguments apply to specific subcommands.
The introduction of aliases (dump and format) simplifies common operations and aims to make the transition to rewatch as the default build system easier.
The new compiler-args subcommand makes the CLI behavior more consistent and predictable.

Copy link

pkg-pr-new bot commented Jun 16, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7551

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7551

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7551

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7551

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7551

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7551

commit: 693a391

@Bushuo
Copy link
Collaborator Author

Bushuo commented Jun 18, 2025

@nojaf to answer you on your comment here rescript-lang/rewatch#162 (comment).
I think this is a great idea. I also think the plan was to eventually replace the legacy commands with commands implemented in rewatch.

@Bushuo Bushuo marked this pull request as ready for review June 18, 2025 07:59
@nojaf
Copy link
Collaborator

nojaf commented Jun 18, 2025

Not sure if relevant here, but I still see 1.2.0 for bunx rewatch --version.
At some point, this should be the rescript version?

rewatch legacy --help doesn't show any help:

(base) nojaf@nojaf-mbp tower-defense % bunx rewatch legacy --help

thread 'main' panicked at src/helpers.rs:252:14:
Could not find rescript-legacy
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I got this with bunx rewatch dump as well.

@Bushuo
Copy link
Collaborator Author

Bushuo commented Jun 18, 2025

Not sure if relevant here, but I still see 1.2.0 for bunx rewatch --version. At some point, this should be the rescript version?

I think the right time for this would be when rewatch is the default cli.

rewatch legacy --help doesn't show any help:

(base) nojaf@nojaf-mbp tower-defense % bunx rewatch legacy --help

thread 'main' panicked at src/helpers.rs:252:14:
Could not find rescript-legacy
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I got this with bunx rewatch dump as well.

I prematurely already look for a binary named rescript-legacy. I guess in this PR we can still look for rescript. I will also add tests for the legacy subcommands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants