wickett / jerry-curl

Wrapper for curl allowing easy inclusion of command line options from a configuration file so your curl commands can go on a serious diet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jerry-curl

Downloading the binary

If you’d like to just grab a pre-compiled binary of jerry-curl, you can grab them here:

Inside of the distrib directory, there are directories for 32 or 64 bit and OS, drill down to the one that you need. Linux, OS X, FreeBSD and Windows binaries available for 32 and 64 bit.

If you clone the repository, you will also have the same distrib directory with pre-compiled binaries for jerry-curl. I provided the direct download for user’s convenience as GitHub doesn’t prompt for downloads of binary files without file extensions.

For Go Devs

You can also download and install jerry-curl using go get.

$ go get github.com/mtesauro/jerry-curl

About jerry-curl

jerry-curl is a wrapper for the curl command which adds options from a configuration file and the command line allowing for short repeated curl calls.

Basically, it helps put your long curl commands on a diet.

The result of a jerry-curl command is a union of what is in the configuration file and the command-line options you add to jerry-curl. Of the command-line options, those meant for jerry-curl are processed and those meant for curl are passed through to curl.

If no configuration file exists, one will be created the first time you run jerry-curl with commented examples in directory named .jerry-curl in your home directory when jerry-curl is run for the first time. For example, user ltorvalds, would have a config file created at /home/ltorvalds/.jerry-curl/jerry-curl.config the first time he ran jerry-curl.

Optionally, you can use a jerry-curl command-line option to point to a different configuration file. Details are below.

Note

DO NOT QUOTE ARGUMENTS TO COMMAND LINE OPTIONS IN THE CONFIGURATION FILE!
jerry-curl will automagically quote them for you - the provided examples do not include quotes.

Using jerry-curl

jerry-curl works by calling curl like the below:

  curl [config options] [BASE][URLPATH] [command-line arguments]

jerry-curl command-line options:

   -c, --config FILE         Select a different config file from the default
                             which is $HOME/.jerry-curl/jerry-curl.config
                               Example: jerry-curl --config=./my-custom-config
   -s, --show                Show the curl command - DO NOT EXECUTE IT
   -u, --url-path URLPATH    Set a path to append to the base URL
                               Example: jerry-curl --url-path=/app/path/here
   -h, --help                help, aka this message
Note

Options --config, -c, -s -u are used by both jerry-curl and curl. jerry-curl will detect when it is unclear if options are for curl or jerry-curl and provide info on the curl alternative options. If you want those options sent to curl, please use the alternate forms. Using --show can help diagnose if jerry-curl or curl is receiving a command-line option

Examples

Assuming you have the following in your configuration file:

    BASE=https://example.com/api/v1
    --proxy 127.0.0.1:8080
    -include
    -H X-Auth-Token: 55555555-5555-5555-5555-555555555555
    -H Accept: application/json
    -H Content-Type: application/json

THe following jerry-curl command:

$ jerry-curl --url-path /uppercase/word -X GET

would result in the following curl command:

$ /usr/bin/curl --proxy 127.0.0.1:8080 -include -H "X-Auth-Token: 55555555-5555-5555-5555-555555555555"
 -H "Accept: application/json" -H "Content-Type: application/json"
-X GET https://example.com/api/v1/uppercase/word

also

$ jerry-curl --url-path /uppercase/word -X POST -d '{"word" : "example"}'

would result in the following curl command:

$ /usr/bin/curl --proxy 127.0.0.1:8080 -include -H "X-Auth-Token: 55555555-5555-5555-5555-555555555555"
-H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"key" : "value"}'
https://example.com/api/v1/uppercase/word

License

jerry-curl is licensed under the GPL v3 and includes the "or later" clause. A reference to the license is in the source for jerry-curl, that is, jerry-curl.go and the full license is in the file LICENSE in the root of the source code directory.

About

Wrapper for curl allowing easy inclusion of command line options from a configuration file so your curl commands can go on a serious diet

License:GNU General Public License v3.0


Languages

Language:Go 100.0%