https://github.com/op/coerl
cörl adds dots, colours and whistles to curl
https://github.com/op/coerl
curl hack
Last synced: about 1 month ago
JSON representation
cörl adds dots, colours and whistles to curl
- Host: GitHub
- URL: https://github.com/op/coerl
- Owner: op
- Created: 2017-09-25T15:46:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-14T19:48:28.000Z (over 8 years ago)
- Last Synced: 2025-05-31T02:13:00.422Z (about 1 year ago)
- Topics: curl, hack
- Language: Go
- Homepage:
- Size: 151 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# coerl
cörl colourises [curl]'s output.
[curl]: https://curl.haxx.se
## Usage
Use coerl instead of curl. curl is still required.
[](coerl.png)
```sh
$ COERL_SSL_DATA_OFF=0 coerl -vs -d '{}'
$ COERL_TEXT_OFF=1 COERL_SSL_DATA_OFF=1 coerl --compressed -sv 'https://api.spotify.com/v1/search' | jq .
$ alias curl=coerl
$ curl -sv -L https://google.com > /dev/null
$ COERL_DATA_OFF=1 COERL_TEXT_OFF=1 curl -sv -L https://google.com > /dev/null
```
## Installation
```sh
$ go get -u github.com/op/coerl
```
## Knobs
Customise coerl by using environmental variables.
* `COERL_CURL_BIN` -- path to executable [curl]
Colors:
* `COERL_HEADER`
* `COERL_TEXT`
* `COERL_DATA`
* `COERL_SSL_DATA`
Silence output:
* `COERL_HEADER_OFF`
* `COERL_TEXT_OFF`
* `COERL_DATA_OFF`
### Even more knobs
These knobs also exist but defaults to the corresponding ones above.
* `COERL_HEADER_OUT`
* `COERL_HEADER_IN`
* `COERL_DATA_IN`
* `COERL_DATA_OUT`
* `COERL_SSL_DATA_IN`
* `COERL_SSL_DATA_OUT`
* `COERL_HEADER_OUT_OFF`
* `COERL_HEADER_IN_OFF`
* `COERL_DATA_IN_OFF`
* `COERL_DATA_OUT_OFF`
* `COERL_SSL_DATA_OFF`
* `COERL_SSL_DATA_IN_OFF`
* `COERL_SSL_DATA_OUT_OFF`
## Background
Short version:
* `-v` has too much data
* `-I` writes to stdout and breaks piping
* colours can help
curl together with its (verbose) output is great in many ways. The
`--include` flag includes the HTTP-header in the output. However this
breaks piping of the output, to eg. [jq] or [rq], since headers are
written to stdout. Using the `--verbose` flag fixes this but also
introduces heaps of output.
[jq]: https://stedolan.github.io/jq/
[rq]: https://github.com/dflemstr/rq
This hack adds some colours to the `--verbose` output of curl.
Credit goes to [httpstat] for inspiration.
[httpstat]: https://github.com/reorx/httpstat
## Limitations
Guessing is done to determine if the data is for SSL or not.