Repository navigation
fix(search): stop clap from capturing -h on rtk grep and rtk rg - #3905
Closed
AngelVRodC wants to merge 1 commit into
Closed
AngelVRodC wants to merge 1 commit into
AngelVRodC wants to merge 1 commit into
Conversation
clap's auto-generated help flag intercepted -h before search.rs could classify it, so `rtk grep -h pattern file` printed rtk's help instead of searching — a silent false negative (exit 0, no matches shown). disable_help_flag removes clap's handling of BOTH -h and --help; the per-engine check in search::run then forwards either form to the engine verbatim. Psql and Ctest already use the same attribute.
AngelVRodC
force-pushed
the
fix/search-flag-correctness
branch
from
September 14, 2026 01:17
bb691d9 to
ea69fff
Compare
Collaborator
|
Thanks for this. I'm closing it as superseded by #4348, which releases clap's help flag on every wrapper subcommand, grep and rg included. On its head, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
rtk grep -h pattern filenever searched: clap's auto-generated help flag intercepted-hbeforesearch.rscould classify it, so rtk printed its own help and exited 0 — a silent false negative. An agent consuming rtk's output sees no matches and no error, and moves on believing the pattern isn't there.The sibling collisions in #3663 (
-l,-m,-t) were already resolved ondevelopby making rtk's own options long-only.-houtlived them because it was clap's auto-generated help flag rather than a declared option, so dropping ashortwasn't possible.Verified on current
develop(d402152): the repro still fires.rtk rg -his affected the same way — there-hgenuinely is rg's--help, but clap prints rtk's help instead of forwarding it.Fix
#[command(disable_help_flag = true)]onCommands::GrepandCommands::Rginsrc/main.rs— 9 lines, comments included.This removes clap's handling of both
-hand--helpfor those two subcommands. The per-engine check already insearch::runthen sees the flag and forwards the argv to the engine verbatim:rtk grep -h alpha a.txtalpha, exit 0rtk grep --helprtk rg -hPsqlandCtestalready carry the same attribute ondevelop; this applies the established pattern where the same collision exists.Why so small
This PR previously contained a full per-engine flag-classification rewrite of
search.rs(4 commits, ~900 lines). While it sat open, upstream merged that capability via #3988/#3998'sarg_tokenizerwork —grep_takes_value/rg_takes_valueper-engine tables cover the-f,-r,-E,-D,--label,--colorfixes this branch originally shipped. Rebased ondevelop, only the clap-hinterception remains unfixed upstream, so the branch was shrunk to exactly that. The old scope is closed; #3665, #3161 and #3881 are resolved by the code already ondevelop.Verification
cargo fmt --all && cargo clippy --all-targets && cargo test --all— clean, 3781 passingrtk rg -n pattern src/still emits grouped/capped outputCloses #3663