1. 8
  1.  

  2. 4

    I use HTTPie when interacting with HTTP. Even in the simple case, http example.com, it adds syntax highlighting to the command-line output. And for API interaction, it requires memorizing fewer command-line flags: compare

    curl --user "smparkes" \
         --request POST \
         --data '{"issue": "15", "head": "smparkes:synchrony", "base": "master"}' \
         https://api.github.com/repos/technoweenie/faraday/pulls
    

    to

    http --auth "smparkes" \
         POST \
         https://api.github.com/repos/technoweenie/faraday/pulls \
         issue=15 head=smparkes:synchrony base=master
    

    HTTPie supports downloading a file with http --download example.com too, though it’s not especially better than curl -O for that use-case.

    1. 3

      HTTPie’s shorthand for JSON is real nice, but I love cURL. So I just hacked together jarg so that I could have that in my own scripts that have to shovel around JSON. You can tighten up the curl invoke a little more now:

      curl -H "Content-Type: application/json" \
          https://smparkes:@api.github.com/repos/technoweenie/faraday/pulls \
          -d "$(jarg issue=15 head=smparkes:synchrony base=master)"
      

      HTTPie is also nice in setting the content type to JSON for you, it’s a pain in cURL. You can fix it with a quick alias though:

      alias curl-json="curl -H'Content-Type: application/json'"
      
      1. 3

        If you don’t mind Python or another high-level language as a dependency, there are a lot of nice curl alternatives. Requiring only libc and being included in many base systems is one of many nice things about curl.

        Amusingly, the whole article could’ve been shortened to, “It’s cat for URLs.”

      2. 1

        I just wish -L was on by default.

        1. 1

          What I wish, and that I think would be much more in keeping with curl’s otherwise fairly “minimalist” approach, would be to default to something like curl -sS – personally I find the progress indications (which are sent to stderr by default) are rarely anything but useless and distracting. The only other common tool I can think of offhand that does something similar is dd, which is hardly a model of how to write a command-line tool that integrates nicely with the rest of the world…