Skip to content

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

Notifications You must be signed in to change notification settings

mtesauro/jerry-curl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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/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/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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages