Skip to content

fix: handle pnpm --filter/-F flag (#259)#520

Open
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes:fix/pnpm-filter-flag
Open

fix: handle pnpm --filter/-F flag (#259)#520
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes:fix/pnpm-filter-flag

Conversation

@ousamabenyounes
Copy link

Summary

Fixes #259rtk pnpm --filter mymodule test fails with "unexpected argument '--filter' found".

Root cause: pnpm's --filter is a global flag that precedes the subcommand (pnpm --filter <pkg> <cmd>). Clap's PnpmCommands subcommand enum expects a subcommand name first, so --filter is rejected as an unknown flag.

Fix: Intercept --filter / --filter= / -F in raw args before Cli::try_parse() and route directly to pnpm_cmd::run_passthrough().

Before/After

# BEFORE
$ rtk pnpm --filter mymodule test
error: unexpected argument '--filter' found
Usage: rtk pnpm [OPTIONS] <COMMAND>

# AFTER — all variants work
$ rtk pnpm --filter mymodule test     # ok
$ rtk pnpm --filter=mymodule test     # ok
$ rtk pnpm -F mymodule test           # ok

Impact

In pnpm monorepos (very common in modern JS/TS), almost every command uses --filter. Without this fix, every pnpm command in a monorepo bypasses RTK filtering = 0% savings instead of 70-90%.

Test plan

  • New test: test_pnpm_filter_detected — verifies detection logic for all 3 variants
  • Full suite: 765 passed, 0 failed
  • Manual verification: --filter, --filter=, -F all pass through to pnpm
  • cargo fmt && cargo clippy && cargo test all green
  • validate-docs.sh passes

Generated with Claude Code

pnpm's --filter is a global flag that precedes the subcommand
(e.g. `pnpm --filter mymod test`). Clap's subcommand enum cannot
handle flags before the subcommand name, causing "unexpected argument
'--filter' found".

Fix: intercept --filter/--filter=/-F in raw args before Cli::try_parse()
and route directly to pnpm passthrough.

Also bumps version strings to 0.28.2 for CI validate-docs.

Fixes rtk-ai#259

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pszymkowiak
Copy link
Collaborator

Hi! Thanks for the contribution! Since March 6, all PRs should target the develop branch instead of master (see CONTRIBUTING.md).

Could you update the base branch? Click Edit at the top right of this PR and change it from master to develop.

Thanks!

@ousamabenyounes ousamabenyounes changed the base branch from master to develop March 11, 2026 22:10
@ousamabenyounes
Copy link
Author

Done sorry! :)

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.

pnpm --filter command results in rtk usage output

2 participants