~shabbyrobe/curl2code

Convert "Copy as cURL" output to code
f529c94b — Blake Williams 1 year, 20 days ago
Fix readme
cb269d37 — Blake Williams 1 year, 28 days ago
Syntax in README
4edd22fa — Blake Williams 1 year, 28 days ago
Add README

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~shabbyrobe/curl2code
read/write
git@git.sr.ht:~shabbyrobe/curl2code

You can also use your local clone with git send-email.

#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://invalid/path", 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.