Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a -H/--with-filename option ala grep, to include the filename in gron'ed output, for when processing multiple files (e.g., within find). #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

RossPatterson
Copy link

I needed to grep for a JSON value across a large collection of files, and found myself doing find . -type f -exec gron {} \; | grep whatever, but then I couldn't identify which files contained the matches. grep has a -H / --with-filename option, that prefixes each output line with filename: fro just such uses (e.g., with grep -r), and that seemed like the right answer. This change adds that option to gron, using "-" for the filename when the input is stdin.

…gron'ed output, for when processing multiple files (e.g., within find).
Copy link

@milahu milahu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

the grep -H style format

testdata/one.json: json = {};
testdata/one.json: json.hello = "world";

is prettier than #28 (comment), for example

file = {};
file["testdata/one.json"] = {};
file["testdata/one.json"].hello = "world";

@RossPatterson
Copy link
Author

It's been several years since I created this PR, but if the gron maintainers are interested in mergong it, I'll make sure the changes are compatible with the current source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants