Skip to content

Fix CLI end-of-options operands for subcommands - #6692

Merged
IMax153 merged 1 commit into
Effect-TS:mainfrom
schickling-assistant:schickling-assistant/2026-07-28-fix-cli-nested-end-of-options
Jul 28, 2026
Merged

Fix CLI end-of-options operands for subcommands#6692
IMax153 merged 1 commit into
Effect-TS:mainfrom
schickling-assistant:schickling-assistant/2026-07-28-fix-cli-nested-end-of-options

Conversation

@schickling-assistant

@schickling-assistant schickling-assistant commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Why

When an effect/unstable/cli subcommand is active, operands after the -- end-of-options terminator are currently attached to the parent parse record. The child therefore reports required positionals as missing and never receives flag-like operands.

What

Forward trailingOperands through recursive subcommand parsing so the innermost active command receives them, while leaving the parent positional list empty. Add regression coverage and a patch changeset for effect.

Rationale

scanCommandLevel can select a subcommand only while awaiting the first positional value. Once a positional is collected, the parser switches permanently to argument collection, so a Sub result cannot contain parent positional arguments. This makes arguments: [] the correct parent representation; the terminator operands belong to the recursively selected child. Forwarding the same list through each recursive level also preserves the rule for multi-level nesting.

Tests

Added coverage for:

  • single-level subcommands with several trailing operands, including --literal and -x
  • multi-level subcommands
  • an empty trailing operand list
  • leaf-command behavior
  • variadic child positionals
  • inherited flags both before and after the subcommand name

Before the parser change, the focused regression selection failed 3 tests while both control cases passed. After the change, all 5 focused cases pass, and the full Command.test.ts file passes 90/90. pnpm lint-fix, pnpm check, pnpm build, and pnpm docgen also pass locally.

Closes #6690

Posted on behalf of @schickling
field value
agent_name co2-scarp
agent_session_id 6b78e583-eb90-415e-8bcb-c4fc342cb179
agent_tool Codex CLI
agent_tool_version 0.145.0
agent_runtime Codex CLI 0.145.0
agent_model unknown
runtime_profile /nix/store/ph8rlhdj25mg71v81jsfzy6dq4xpcs9m-coding-agent-runtime-profile/share/coding-agents/profile.json
skills_manifest /nix/store/lsykz8x5481xrpbgk280xh3pypk1c5jy-agent-skills-corpus/share/agent-skills/manifest.json
worktree effect/schickling-assistant/2026-07-28-fix-cli-nested-end-of-options
machine dev3
tooling_profile dotfiles@3649b53

Summary by CodeRabbit

  • Bug Fixes

    • Fixed CLI parsing so operands after -- are preserved instead of being dropped.
    • Ensured these operands are correctly passed to selected and nested subcommands.
    • Preserved trailing operands for commands with variadic positional arguments.
    • Parent command flags continue to apply when -- is used, including without trailing operands.
  • Tests

    • Added coverage for -- handling across subcommands, nested commands, and leaf commands.

agent-session-id: 6b78e583-eb90-415e-8bcb-c4fc342cb179
agent-tool: Codex CLI
agent-tool-version: 0.145.0
agent-model: unknown
agent-runtime-profile: /nix/store/ph8rlhdj25mg71v81jsfzy6dq4xpcs9m-coding-agent-runtime-profile/share/coding-agents/profile.json
agent-skills-manifest: /nix/store/lsykz8x5481xrpbgk280xh3pypk1c5jy-agent-skills-corpus/share/agent-skills/manifest.json
tooling-profile: dotfiles@3649b53
@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 28, 2026
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0098d73

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 29 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 318a6b5a-6204-423f-a3b4-2a14a10df087

📥 Commits

Reviewing files that changed from the base of the PR and between 45e7810 and 0098d73.

📒 Files selected for processing (3)
  • .changeset/quiet-clis-parse.md
  • packages/effect/src/unstable/cli/internal/parser.ts
  • packages/effect/test/unstable/cli/Command.test.ts

📝 Walkthrough

Walkthrough

The CLI parser now forwards operands after -- to selected subcommands instead of retaining them on the parent parse record. Tests cover nested commands, leaf variadic arguments, empty terminators, and inherited flags. A patch changeset documents the fix.

Changes

CLI terminator operand forwarding

Layer / File(s) Summary
Forward terminator operands through subcommands
packages/effect/src/unstable/cli/internal/parser.ts, packages/effect/test/unstable/cli/Command.test.ts, .changeset/quiet-clis-parse.md
parseArgs passes operands after -- into child parsing and clears them from the parent result; tests validate nested and leaf commands, empty terminators, and inherited flags, and the changeset records a patch release.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: imax153

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The parser now forwards trailing operands into nested subcommand parsing, so the active child receives -- operands as required by #6690.
Out of Scope Changes check ✅ Passed The only non-code change is a patch changeset, and the code/test edits stay focused on the nested-subcommand -- parsing bug.

Comment @coderabbitai help to get the list of available commands.

@effect-slopcop effect-slopcop Bot added 4.0 bug Something isn't working labels Jul 28, 2026
@schickling-assistant

Copy link
Copy Markdown
Contributor Author

Local verification:

  • Before the parser patch, pnpm --filter effect test --run test/unstable/cli/Command.test.ts -t "trailing operands" reproduced the regression: 3 failed and 2 passed. The single-level, multi-level, and inherited-flag subcommand cases failed; the empty-operand and leaf-command controls passed.
  • With the patch, the same focused command passes all 5 tests.
  • pnpm --filter effect test --run test/unstable/cli/Command.test.ts passes all 90 tests.
  • pnpm lint-fix passes with 0 warnings and 0 errors, including dprint formatting.
  • pnpm check, pnpm build, and pnpm docgen pass.
Posted on behalf of @schickling
field value
agent_name co2-scarp
agent_session_id 6b78e583-eb90-415e-8bcb-c4fc342cb179
agent_tool Codex CLI
agent_tool_version 0.145.0
agent_runtime Codex CLI 0.145.0
agent_model unknown
runtime_profile /nix/store/ph8rlhdj25mg71v81jsfzy6dq4xpcs9m-coding-agent-runtime-profile/share/coding-agents/profile.json
skills_manifest /nix/store/lsykz8x5481xrpbgk280xh3pypk1c5jy-agent-skills-corpus/share/agent-skills/manifest.json
worktree effect/schickling-assistant/2026-07-28-fix-cli-nested-end-of-options
machine dev3
tooling_profile dotfiles@3649b53

@schickling-assistant
schickling-assistant marked this pull request as ready for review July 28, 2026 08:03
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.63 KB 6.63 KB 0.00 KB (0.00%)
batching.ts 9.37 KB 9.42 KB -0.05 KB (-0.51%)
brand.ts 6.26 KB 6.29 KB -0.04 KB (-0.57%)
cache.ts 10.12 KB 10.12 KB 0.00 KB (0.00%)
config.ts 19.22 KB 19.77 KB -0.55 KB (-2.79%)
differ.ts 18.42 KB 18.96 KB -0.54 KB (-2.84%)
http-client.ts 20.88 KB 20.94 KB -0.06 KB (-0.29%)
logger.ts 10.28 KB 10.28 KB 0.00 KB (0.00%)
metric.ts 8.55 KB 8.55 KB 0.00 KB (0.00%)
optic.ts 7.41 KB 7.45 KB -0.04 KB (-0.50%)
pubsub.ts 14.20 KB 14.26 KB -0.06 KB (-0.41%)
queue.ts 11.09 KB 11.09 KB 0.00 KB (0.00%)
schedule.ts 10.27 KB 10.27 KB 0.00 KB (0.00%)
schema-class.ts 18.16 KB 18.72 KB -0.55 KB (-2.95%)
schema-fromJsonSchemaDocument.ts 28.02 KB 28.69 KB -0.67 KB (-2.34%)
schema-representation-roundtrip.ts 24.34 KB 24.98 KB -0.64 KB (-2.57%)
schema-string-transformation.ts 12.69 KB 12.96 KB -0.27 KB (-2.07%)
schema-string.ts 10.35 KB 10.65 KB -0.30 KB (-2.81%)
schema-template-literal.ts 14.49 KB 14.85 KB -0.36 KB (-2.42%)
schema-toArbitraryLazy.ts 20.93 KB 21.52 KB -0.59 KB (-2.73%)
schema-toCodeDocument.ts 23.38 KB 24.00 KB -0.63 KB (-2.61%)
schema-toCodecJson.ts 18.32 KB 18.87 KB -0.55 KB (-2.93%)
schema-toEquivalence.ts 18.00 KB 18.59 KB -0.58 KB (-3.13%)
schema-toFormatter.ts 17.88 KB 18.45 KB -0.57 KB (-3.11%)
schema-toJsonSchemaDocument.ts 21.52 KB 22.08 KB -0.57 KB (-2.57%)
schema-toRepresentation.ts 18.56 KB 19.13 KB -0.58 KB (-3.02%)
schema.ts 17.43 KB 18.00 KB -0.56 KB (-3.14%)
stm.ts 12.05 KB 12.05 KB 0.00 KB (0.00%)
stream.ts 9.37 KB 9.37 KB 0.00 KB (0.00%)

@IMax153
IMax153 merged commit 3eeea73 into Effect-TS:main Jul 28, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Done in PR Backlog Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

unstable/cli: -- operands are dropped for nested subcommands

2 participants