Add -B, -A, and -C options to grep#1206
Conversation
nfischer
left a comment
There was a problem hiding this comment.
Thanks for implementing this feature. I've provided some initial feedback that you can get started on now, but I'll need to spend more time reviewing this (expect more feedback later).
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1206 +/- ##
==========================================
+ Coverage 97.37% 97.46% +0.08%
==========================================
Files 35 35
Lines 1410 1459 +49
==========================================
+ Hits 1373 1422 +49
Misses 37 37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Sorry about the commit mess. I'm not sure why checks are failing on macos and ubuntu now. |
Oh, this should be a simple fix. Can you run If that doesn't fix it, then try running the tests locally and run |
Hey, that worked, thanks! Hopefully everything looks good now. |
nfischer
left a comment
There was a problem hiding this comment.
LGTM, but with a few more suggestions.
Thanks for working on this feature!
|
Released in shelljs v0.10. Thanks for the contribution! |
This adds support for shelljs/shelljs#1206. This requires special parsing logic on the shx side. Test: npm test Test: ./lib/cli.js grep -A 1 'foo' ~/foobartest.txt Test: cat ~/foobartest.txt | ./lib/cli.js grep -A 1 'foo'
This adds support for shelljs/shelljs#1206. This requires special parsing logic on the shx side. Test: npm test Test: ./lib/cli.js grep -A 1 'foo' ~/foobartest.txt Test: cat ~/foobartest.txt | ./lib/cli.js grep -A 1 'foo'
This adds support for shelljs/shelljs#1206. This requires special parsing logic on the shx side. Test: npm test Test: ./lib/cli.js grep -A 1 'foo' ~/foobartest.txt Test: cat ~/foobartest.txt | ./lib/cli.js grep -A 1 'foo'
Adds the
-B(before context) and-A(after context) options to grep. I may have gone overboard on tests but I wanted to make sure that most feasible configurations work (combined, separate, with space, without space).Notes
globStartto accept a function with a parameterargs. This allows-Band-Ato be specified separately and a function to determine where the post-regex arguments begin..editorconfig: Single quotes in JavaScript files.eslintrc.json:radixoption tooff(don't require base forparseInt())package.json: PrettierarrowParensoption toavoid(don't wrap single parameters in parentheses for arrow functions)Usage
Examples