-
Notifications
You must be signed in to change notification settings - Fork 469
Rust implementation of "rescript format" #7603
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
base: master
Are you sure you want to change the base?
Conversation
rescript
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/win32-x64
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rewatch format --help
thread 'main' panicked at /Users/nojaf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/clap_builder-4.5.31/src/builder/debug_asserts.rs:570:9:
Positional argument `[FOLDER]` *must* have `required(true)` or `last(true)` set because a prior positional argument (`[FILES]...`) has `num_args(1..)`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
There is something weird in the setup here, the help crashes.
Might be related to the files: Vec<string>
, but I'm not sure.
/// Format the whole project. | ||
#[arg(short = 'a', long)] | ||
all: bool, | ||
/// Check formatting for file or the whole project. Use `--all` to check the whole project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--all
is actually -all
in bsb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this will be a breaking changes I would say.
|
||
|
||
fn format_all(bsc_exe: &Path, check: bool) -> Result<()> { | ||
let output = Command::new(std::env::current_exe()?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewatch doesn't have an info
command like rescript
did have. So this call won't work and it also is not future proof as this won't work for monorepos.
@jfrolich would it make sense to call packages::make()
instead and iterate through all packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Also realized this yesterday. Didn't test with --all
before. 🤦♂️
Yes, this needs to be implemented on the rewatch
side.
cli/rescript.js
Outdated
@@ -18,7 +18,8 @@ try { | |||
subcommand === "build" || | |||
subcommand === "watch" || | |||
subcommand === "clean" || | |||
subcommand === "compiler-args" | |||
subcommand === "compiler-args" || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Maybe we can collect all subcommands in a Set
and call .contains?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or use a switch
statement.
Do not forward the
rescript format
command to the legacy JS cli anymore, instead implement the functionality natively in Rust.Mostly written by Gemini CLI. Would be good if someone with more Rust knowledge than me could review.