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

Ungron to ignore lines saying -- #15

Closed
marcus-downing opened this issue Aug 30, 2016 · 5 comments
Closed

Ungron to ignore lines saying -- #15

marcus-downing opened this issue Aug 30, 2016 · 5 comments

Comments

@marcus-downing
Copy link

marcus-downing commented Aug 30, 2016

Grep can search for lines immediately preceding or following the matched line, using grep -A, grep -B or grep -C. However the output of these includes separator lines that read --. This output currently produces an error when you try to ungron the result.

Since grep is a primary use for gron, I believe it would be a useful enhancement for it to accept a common output of grep. It doesn't need to do anything with the lines, only match and exclude them.

For example:

$ gron file.json | grep -A 1 'ktoe per year'
json.resources.geothermal.production.units = "ktoe per year";
json.resources.geothermal.production.value = 2007.738525390625;
--
json.resources.hydropower.production.units = "ktoe per year";
json.resources.hydropower.production.value = 9038.80078125;
--
json.resources.wind.production.units = "ktoe per year";
json.resources.wind.production.value = 381.5000305175781;
@tomnomnom
Copy link
Owner

Sounds like a good call to me!

It's workaround-able with a grep -v '^--' before the ungron, but it seems like it'd be a common enough occurrence to be worthwhile implementing.

I'll have a look at implementing it this evening, unless someone beats me to it of course :)

Thanks for the suggestion!

@tomnomnom
Copy link
Owner

@marcusatbang sorry it took so long!

Version 0.3.2 should now not have this problem :)

@marcus-downing
Copy link
Author

That was remarkably fast. Well done.

@marcus-downing
Copy link
Author

Confirmed as working.

@tomnomnom
Copy link
Owner

Fantastic! Glad to hear it :)

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

No branches or pull requests

2 participants