Repository navigation
Conversation
34edd88 to
01a3b97
Compare
3049200 to
6e5afa9
Compare
GNU/BSD grep -h is --no-filename, but rtk grep -h printed the rtk help banner: clap intercepted -h before run() saw it, and the --version/--help passthrough also treated -h as help. Free -h via disable_help_flag plus a long-only --help (ArgAction::Help), so rtk grep --help still shows rtk help while -h reaches the search path. rtk forces -H --null for NUL-delimited parsing, so a forwarded -h (last-wins) would suppress the filename at the engine, break parsing, and drop line numbers. Strip -h/--no-filename from the engine args (letter-wise in clusters like -hi) and re-apply no-filename purely at the display layer (show_file = false), so output matches grep -n -h. Replaces the obsolete GNU-arg IR layer (former brief 002): upstream rtk-ai#2641 (grep runs grep, rg runs rg) removed the flag-collision class the IR solved, leaving only this -h slice. Tests pin rtk grep -h / -hi == grep -n -h, that --help still shows help, and that \| keeps its per-dialect meaning (literal in -E/-F, alternation in BRE) against grep -n.
6e5afa9 to
71b49c9
Compare
…g-layer # Conflicts: # src/cmds/system/search.rs # src/main.rs # tests/grep_faithful_format_test.rs
|
Closing in favour of #3888, which is the better fix for this. Two things it does that this PR doesn't:
Also credit where it's due: #2532 proposed One thing worth carrying over from here, though — with /// Print rtk grep help (long-only; `-h` is GNU grep's --no-filename)
#[arg(long, action = clap::ArgAction::Help)]
help: Option<bool>,That may well be a deliberate call for a proxy (show the wrapped tool's help), but if not, it's a cheap addition to #3888. Last note, in case it saves someone a debugging session: I stripped |
Why
GNU/BSD
grep -his--no-filename— it suppresses the filename prefix. Butrtk grep -h <pattern> <file>printed rtk's own--helpbanner (exit 0, no search): clap intercepted-has help beforerun()ever saw it, and the--version/--helppassthrough also treated-has help. An agent that typesgrep -hgot a help screen instead of matches — a silent false negative.What
-hin clap (main.rs):#[command(disable_help_flag = true)]onGrep, with a re-added long-only--help(ArgAction::Help).rtk grep --helpstill shows rtk's help;-hnow reaches the arg layer.-has help in the--version/--helppassthrough (search.rs).-h/--no-filenamefrom the engine args before running it: rtk forces-H --nullfor NUL-delimited parsing, so a forwarded-h(last-wins) would suppress the filename at the engine, break parsing, and drop line numbers. Stripping is letter-wise inside clusters (-hi→-i; a bare-his dropped). No-filename is then re-applied purely at the display layer (show_file = false), so output matchesgrep -n -h.Files
src/main.rs— free-h(disable_help_flag+ long-only--help).src/cmds/system/search.rs— drop-hfrom the help passthrough;strip_no_filename()for the engine args;show_filehonors no-filename.tests/grep_faithful_format_test.rs—rtk grep -h/-himust equalgrep -n -h(and never print rtk help).Test plan
cargo fmt --all --check && cargo clippy --all-targetsrtk grep -h <pat> <f1> <f2>==grep -n -h …(position + content, no filename, no help banner).rtk grep -hi <pat> …honors no-filename and ignore-case (cluster stripping).rtk grep --helpstill prints rtk's help; existingsearch_*/grep_*suites stay green.Context
Closes the residual of #2391 (
-h=--no-filename) after #2641 absorbed the rest of the flag-collision class. The obsolete IR-layer commits are dropped from this branch (preserved locally as a backup); the upstream-tracked issue set is unchanged.