Skip to content

Comments

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
RossPatterson wants to merge 2 commits intotomnomnom:masterfrom
RossPatterson:master

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.

@RossPatterson
Copy link
Author

Nothing heard.

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