Skip to content

## Fix: support unquoted --flags in wrap commands for effect/unstable/cli#625

Open
jfet97 wants to merge 2 commits intor/effect-v4-2from
fix/cli-argv-patch-wrap-commands
Open

## Fix: support unquoted --flags in wrap commands for effect/unstable/cli#625
jfet97 wants to merge 2 commits intor/effect-v4-2from
fix/cli-argv-patch-wrap-commands

Conversation

@jfet97
Copy link
Collaborator

@jfet97 jfet97 commented Mar 3, 2026

The new effect/unstable/cli lexer tokenizes all --flags as LongOption tokens upfront, at the lexer level, before any command routing happens. When a subcommand like packagejson or index-multi receives args like tsc --build, the lexer classifies --build as a LongOption. The subcommand parser then discards it as an unrecognized flag — unlike the old @effect/cli which treated unrecognized flags as positional args.

Why -- doesn't work: the lexer splits on -- at the top level, putting everything after it into trailingOperands. But these operands stay at the parent command level and don't propagate down to the subcommand's argument parser.

Solution: an argv pre-processor joins all args after a wrap-enabled subcommand (index-multi, packagejson, packagejson-packages) into a single string element before the CLI parser runs. The lexer sees one Value token (e.g. "tsc --build") instead of Value("tsc") + LongOption("build"). The wrap handler already passes this string to sh -c, so the shell handles the splitting correctly.

No changes needed in consumer projects (macs-scanner, configurator, signalznow).

Tests

  • 18 unit tests for the argv patch function (wrap/non-wrap subcommands, edge cases)
  • 5 e2e tests that spawn the actual CLI binary and verify the wrap command is executed, output is correct, and exit codes propagate

The new effect/unstable/cli lexer classifies --flags as LongOption tokens
and discards unrecognized ones. This patch auto-inserts "--" after
wrap-enabled subcommands so that `effect-app-cli index-multi tsc --build`
works without quoting, maintaining backward compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jfet97 jfet97 changed the base branch from main to r/effect-v4-2 March 3, 2026 17:18
@jfet97 jfet97 marked this pull request as draft March 3, 2026 17:21
@jfet97 jfet97 changed the title Fix/cli argv patch wrap commands ## Fix: support unquoted --flags in wrap commands for effect/unstable/cli Mar 3, 2026
@jfet97 jfet97 marked this pull request as ready for review March 3, 2026 17:26
@jfet97 jfet97 requested a review from patroza March 3, 2026 17:27
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.

1 participant