~shabbyrobe/curl2code

4edd22fac3df10a0807f374d7751f4d3db7679f2 — Blake Williams 1 year, 1 month ago 93c7991
Add README
1 files changed, 50 insertions(+), 0 deletions(-)

A README.md
A README.md => README.md +50 -0
@@ 0,0 1,50 @@
# curl2code: Convert "Copy as cURL" output to code (hopefully)

Very simple tool that stickytapes a shell parser to stdin and quacks
out some code to drive an HTTP client.

Can save a lot of time when using browser dev tools.

Example:

```
echo "curl --request GET \
  --url http://invalid/path \
  --user-agent 'FLEEB' \
  --header 'A: B C'" \
  | curl2code
```

Output:

```
client := http.Client{
	Timeout: 10 * time.Second,
}
rq, err := http.NewRequest("GET", "http://localhost:3000/api/trpc/content.getHomepage", nil)
if err != nil {
	return err
}
rq.Header.Set("User-Agent", "FLEEB")
rq.Header.Set("A", "B C")

rs, err := client.Do(rq)
if err != nil {
	return err
}
```


## Expectation management

This is a tool I hack on for my own amusement in an ad-hoc fashion. *No
stability guarantees are made*, the code is *not guaranteed to work*, and
anything may be changed, renamed or removed at any time as I see fit.

If you wish to use any of this, I strongly recommend you copy-paste pieces
as-needed (including tests and license/attribution) into your own project,
or fork it for your own purposes.

Bug reports are welcome, feature requests discouraged, and code contributions
will not be accepted.