fix(cli): make --eval-file flag work without equals sign #31151
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #30958 by removing the
require_equals(true)constraint from the--eval-fileflag, making the equals sign optional.Problem
The
--eval-fileflag currently requires an equals sign (--eval-file=file.ts), which makes it impossible to use in hashbang contexts where arguments cannot contain equals signs.Solution
Removed
.require_equals(true)from the flag definition incli/args/flags.rs, allowing both syntaxes:deno repl --eval-file script.ts(new, works with hashbangs)deno repl --eval-file=script.ts(still works, backwards compatible)deno repl --eval-file 1.ts --eval-file 2.ts(multiple files)Changes
require_equals(true)constraint from--eval-fileflag--eval-fileflagsTesting
Added two new test cases:
repl_with_eval_file_flag_no_equals- Tests--eval-file script.tssyntaxrepl_with_eval_file_flag_multiple- Tests multiple flagsThe existing test
repl_with_eval_file_flagcontinues to work, ensuring backwards compatibility.Use Case
This enables the following hashbang usage: