You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rtk grep declares extra_args: Vec<String> with trailing_var_arg = true, but Clap still intercepts short flags like -i, -r, -n, -A etc. before reaching the trailing var arg. This means:
grep: The trailing_var_arg on extra_args doesn't work as expected — Clap intercepts short flags before they reach extra_args. Consider using allow_hyphen_values = true on extra_args, or moving to a -- separator approach in the Clap definition
Hook template: The default hook in the README should handle these edge cases — happy to contribute the full working hook if helpful
Context
The recommended Claude Code hook blindly prefixes
findandgrep/rgcommands withrtk, which breaks in many common cases (relates to #204, #229).find— syntax mismatchrtk findhas a completely different syntax than GNUfind:find <path> <predicates>(e.g.,find . -not -path '*/.git/*' -name '*.pdf')rtk find <PATTERN> [PATH] [--max N] [-t f|d]The hook rewrites
find . -not -path ... | head -n 500→rtk find . -not -path ... | head -n 500, which fails because:-not,-path,-type,-exec, etc.| head -nget their flags parsed by Clap (the-nerror fromfindandgrepcommands fail (unexpected argument '-n' found) #204)grep— Clap intercepts rg flagsrtk grepdeclaresextra_args: Vec<String>withtrailing_var_arg = true, but Clap still intercepts short flags like-i,-r,-n,-Aetc. before reaching the trailing var arg. This means:rtk grep -i "pattern" .→error: unexpected argument '-i' foundrtk grep -rn "pattern" .→error: unexpected argument '-n' found(grep: unexpecter argument #229)The only way to pass rg flags is AFTER the positionals:
rtk grep "pattern" path -- -iWorkaround: smart hook translation
We wrote a hook that properly translates instead of blindly prefixing:
find— syntax translation with safety guardsgrep— flag reorganizationSuggestions for RTK
find: Consider either addingexternal_subcommand/ passthrough fallback (like PR feat: passthrough fallback when Clap parse fails + review fixes #200 suggests), or documenting that the hook should translate syntax rather than prefixgrep: Thetrailing_var_argonextra_argsdoesn't work as expected — Clap intercepts short flags before they reachextra_args. Consider usingallow_hyphen_values = trueonextra_args, or moving to a--separator approach in the Clap definitionEnvironment