Repository navigation
Conversation
Why:
normalize_argv rewrote argv so that Rust-era forms (a bare folder,
options before the command, -h/-V clusters) kept working on Cmdliner.
Its help/version precedence dropped positional words, so an unknown
command followed by --help or --version printed help or the version
and exited with 0. Only -h and -V remain as aliases now.
Diagnostic modified (unknown command with a display flag):
Before (text):
$ rescript invalid --help
NAME
rescript - Fast, Simple, Fully Typed JavaScript from the Future
…
exit 0
After (text):
$ rescript invalid --help
Usage: rescript [--help] [COMMAND] …
rescript: unknown command invalid. Must be one of build, clean,
compiler-args, format, help or watch
exit 2
Diagnostic modified (options before the command):
Before (text):
$ rescript -v build
(builds the current folder with debug output)
After (text):
$ rescript -v build
Usage: rescript [--help] [COMMAND] …
rescript: options go after the command: rescript build [OPTION]… (write
./build for a folder named build)
exit 2
Diagnostic modified (bare folder):
Before (text):
$ rescript ./pkg
(builds ./pkg)
After (text):
$ rescript ./pkg
rescript: unknown command ./pkg. Must be one of build, clean, …
exit 2
Review: Why reject in the default term instead of scanning argv? Options such as -f take a value, so a scan cannot tell `-f build` from `-v build`; Cmdliner has already parsed the options when the default term sees a folder named like a command.
Breaking: `rescript <folder>` becomes `rescript build <folder>`, options go after the command (`rescript build -v`), and -h/-V no longer combine with other flags in one cluster.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gLt5FhNDjMw2sNude8
Signed-off-by: Christoph Knittel <ck@cca.io>
Changelog💥 Breaking Change
Semantic Diff2 commits · Full page Require the command before options in the build system's CLI0247e6f · cknitt + Claude · Nov 08, 2026, 18:06 UTC
Diagnostic modified (unknown command with a display flag)
$ rescript invalid --help
-NAME
- rescript - Fast, Simple, Fully Typed JavaScript from the Future
-…
-exit 0
+Usage: rescript [--help] [COMMAND] …
+rescript: unknown command invalid. Must be one of build, clean,
+ compiler-args, format, help or watch
+exit 2Diagnostic modified (options before the command)
$ rescript -v build
-(builds the current folder with debug output)
+Usage: rescript [--help] [COMMAND] …
+rescript: options go after the command: rescript build [OPTION]… (write
+ ./build for a folder named build)
+exit 2Diagnostic modified (bare folder)
$ rescript ./pkg
-(builds ./pkg)
+rescript: unknown command ./pkg. Must be one of build, clean, …
+exit 2
Review
|
✅ Compiler benchmarksAllocated wordsIn total: 456,989,425 → 456,989,425 (±0.00%). None of the 257 benchmarks changed by 0.1% or more. InstructionsIn total: 10,226,961,997 → 10,226,961,997 (±0.00%). None of the 33 benchmarks changed by 0.1% or more. Pull request 3a9a1d2 compared with base d47adb3 in this run. |
CI forces colors, and Cmdliner then quotes the command name instead of styling it, so the test checks the message and the name separately. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kbf3gLt5FhNDjMw2sNude8 Signed-off-by: Christoph Knittel <ck@cca.io>
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9266 |
rescriptrewrote its argv before Cmdliner parsed it, so that command lines written for the Rust build system kept working. This PR removes most of that. What's left is-has an alias for--helpand-Vfor--version, since Cmdliner only defines the long names.Command lines that change:
rescript ./pkgbuilds./pkgrescript build ./pkgrescript -v build,rescript -q watchrescript build -vrescript -vh,rescript -Vh(help/version clustered with other flags)-hor-Valonerescript bogus --helpprinted the root help and exited with 0rescript,rescript --prod ./pkg,rescript cleanand every command-first form behave as before. rescript-vscode and the create-rescript-app templates put the command first wherever they name one.Without the rewrite, Cmdliner reads a command name after an option as the default build's folder, so
rescript -v buildwould build a folder namedbuild. The default build therefore rejects a folder spelled exactly like a command and points to./buildfor a real folder of that name.Supersedes #9264, whose bug can't happen once nothing drops positional arguments.
Tests: the cluster and options-first cases are replaced with cases asserting the new errors for a bare folder,
-v buildandbogus --help/-V. The test scripts that put-q/-v/-vvbefore the command now put them after it.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gLt5FhNDjMw2sNude8