danielgtaylor / restish

Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in
https://rest.sh/
MIT License
900 stars 74 forks source link

feat: add gron greppable output format #196

Closed danielgtaylor closed 1 year ago

danielgtaylor commented 1 year ago

This PR adds the awesome gron format as a built-in output format for Restish. It makes it easy to explore new or rarely used APIs right from the terminal by enabling easy grepping that includes structured path information in the output. Use it via:

# Gron output example
$ restish api.rest.sh/types -o gron
HTTP/2.0 200 OK
...

body = {};
body.$schema = "https://api.rest.sh/schemas/TypesModel.json";
body.boolean = true;
body.integer = 42;
body.nullable = null;
body.number = 123.45;
body.object = {};
body.object.binary = "3q3A3g==";
body.object.binary_long = "AAECAwQFBgcICQoLDA0ODw==";
body.object.date = "2023-06-17T00:00:00Z";
body.object.date_time = "2023-06-17T16:16:35.74384951Z";
body.object.url = "https://rest.sh/";
body.string = "Hello, world!";
body.tags = [];
body.tags[0] = "example";
body.tags[1] = "short";

# Easy to grep and see the path/structure
$ restish api.rest.sh/types -o gron | grep date
body.object.date = "2023-06-17T00:00:00Z";
body.object.date_time = "2023-06-17T16:16:48.840596241Z";
codecov[bot] commented 1 year ago

Codecov Report

Merging #196 (1a9df79) into main (d9c4f96) will increase coverage by 0.60%. The diff coverage is 98.87%.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/danielgtaylor/restish/pull/196/graphs/tree.svg?width=650&height=150&src=pr&token=1BMagYibk9&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+G.+Taylor)](https://app.codecov.io/gh/danielgtaylor/restish/pull/196?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+G.+Taylor) ```diff @@ Coverage Diff @@ ## main #196 +/- ## ========================================== + Coverage 74.95% 75.55% +0.60% ========================================== Files 25 26 +1 Lines 3406 3494 +88 ========================================== + Hits 2553 2640 +87 - Misses 655 656 +1 Partials 198 198 ``` | [Impacted Files](https://app.codecov.io/gh/danielgtaylor/restish/pull/196?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+G.+Taylor) | Coverage Δ | | |---|---|---| | [cli/content.go](https://app.codecov.io/gh/danielgtaylor/restish/pull/196?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+G.+Taylor#diff-Y2xpL2NvbnRlbnQuZ28=) | `73.72% <83.33%> (+0.23%)` | :arrow_up: | | [cli/cli.go](https://app.codecov.io/gh/danielgtaylor/restish/pull/196?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+G.+Taylor#diff-Y2xpL2NsaS5nbw==) | `71.55% <100.00%> (+0.06%)` | :arrow_up: | | [cli/gron.go](https://app.codecov.io/gh/danielgtaylor/restish/pull/196?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+G.+Taylor#diff-Y2xpL2dyb24uZ28=) | `100.00% <100.00%> (ø)` | | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/danielgtaylor/restish/pull/196?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+G.+Taylor). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+G.+Taylor) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/danielgtaylor/restish/pull/196?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+G.+Taylor). Last update [d9c4f96...1a9df79](https://app.codecov.io/gh/danielgtaylor/restish/pull/196?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+G.+Taylor). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniel+G.+Taylor).