expose --after-context/-A, --before-context/-B, --context/-C command-line options mimicking the corresponding ripgrep options (for showing "contextual lines" around match lines
Not in this PR:
ripgrep appears to be doing some more sophisticated "resolution" of its supplied command-line flags eg it appears that "order matters" if you specify "competing" flags (like both --context + --after-context). If we wanted to support that I believe we would have to abandon the clap-#[derive(...)]-based approach (because it doesn't expose things like order of the command-line arguments to you)? So that seems like it would be a big "choice" to make but I didn't see it as super compelling to jump into that to maintain that level of ripgrep-"compatibility" at the moment
To test:
Per newly added test cases you should see surrounding lines around matches being printed basically the way ripgrep does it by default (just without color formatting) when you specify one or more (see above caveat) of the context-lines command-line options
In this PR:
--after-context
/-A
,--before-context
/-B
,--context
/-C
command-line options mimicking the correspondingripgrep
options (for showing "contextual lines" around match linesNot in this PR:
ripgrep
appears to be doing some more sophisticated "resolution" of its supplied command-line flags eg it appears that "order matters" if you specify "competing" flags (like both--context
+--after-context
). If we wanted to support that I believe we would have to abandon theclap
-#[derive(...)]
-based approach (because it doesn't expose things like order of the command-line arguments to you)? So that seems like it would be a big "choice" to make but I didn't see it as super compelling to jump into that to maintain that level ofripgrep
-"compatibility" at the momentTo test: Per newly added test cases you should see surrounding lines around matches being printed basically the way
ripgrep
does it by default (just without color formatting) when you specify one or more (see above caveat) of the context-lines command-line optionsBased on
custom-grep