Skip to content

fix(cli): preserve double dash before entrypoint - #36794

Open
Tiancheng-Xu wants to merge 3 commits into
denoland:mainfrom
Tiancheng-Xu:fix/36792-double-dash-positional
Open

fix(cli): preserve double dash before entrypoint#36794
Tiancheng-Xu wants to merge 3 commits into
denoland:mainfrom
Tiancheng-Xu:fix/36792-double-dash-positional

Conversation

@Tiancheng-Xu

@Tiancheng-Xu Tiancheng-Xu commented Sep 8, 2026

Copy link
Copy Markdown

Summary

  • preserve -- as an end-of-options separator before the first positional entrypoint
  • continue routing arguments after the entrypoint to the command trailing arguments
  • add focused parser regressions for run, eval, and root-script forms

Validation

  • cargo test -p deno_cli_parser --lib --offline --features deno_core/v8: 379 passed
  • debug deno binary built successfully
  • focused CLI smoke matrix for eval --, run --, leading-hyphen scripts, and trailing arguments passed
  • cargo fmt --all -- --check passed
  • git diff --check passed

./x check was stopped after it expanded into a full-repository compile beyond this two-file parser change.

Fixes #36792

AI assistance disclosure

This PR was prepared with assistance from ChatGPT/Codex.

Copilot AI lite review requested due to automatic review settings September 8, 2026 01:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new positional_only path diverges from existing trailing/---stripping and unexpected-positional error behavior, which can mis-handle argv in real CLI invocations.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the libs/cli_parser argument parser to treat -- as an end-of-options separator before the first positional “entrypoint” (ex: deno run -- -echo.ts), restoring behavior needed for leading-hyphen scripts/code and keeping post-entrypoint arguments routed to trailing args.

Changes:

  • Add a positional_only parsing mode to consume initial positionals after -- without interpreting leading - as flags.
  • Preserve existing trailing-arg behavior after the entrypoint (including keep_double_dash semantics).
  • Add regression tests covering run -- <script> and eval -- <code>.
File summaries
File Description
libs/cli_parser/src/parse.rs Implements positional_only parsing after -- prior to the first positional.
libs/cli_parser/src/tests.rs Adds parser regressions for run and eval using -- before entrypoint/code.
Review details

Suppressed comments (1)

libs/cli_parser/src/parse.rs:192

  • When positional_only is active and there are more argv tokens than there are positional defs, the parser currently pushes the extras into result.trailing unconditionally. That differs from the normal parsing path (which errors with UnexpectedPositional when trailing_var_arg is false) and can cause commands like deno info -- -file.ts extra to be accepted unexpectedly.
      result.trailing.push(arg.clone());
      i += 1;
      continue;
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread libs/cli_parser/src/parse.rs
Comment thread libs/cli_parser/src/tests.rs
@Tiancheng-Xu

Copy link
Copy Markdown
Author

Addressed the Copilot review in commit 6ab567a9: positional-only parsing now returns UnexpectedPositional when trailing_var_arg is disabled, matching the normal parser path. Added a regression covering deno upgrade -- v1 v2. git diff --check passes; cargo is unavailable in this environment, so I could not rerun the Rust test target locally. The PR already includes the required AI-assistance disclosure.

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.

🐛deno eval/run ... no longer respect -- (end of options signal)

3 participants