Live data from Hacker News

Just Use Curl

justuse.org

141–150 of 154 posts

Re: Just Use Curl

#141

I love curl and use it all the time (copying requests from the browser is maybe the most common usage) but: > Q: But Postman has testing and automation! > A: So does cURL in a shell script with || and && and actual programming languages. You want assertions? Pipe to grep or write a 3-line Python script. Done. IMO if you're reaching for an "actual programming language" it's probably time to put curl down and switch to…

The Google style guide is a good reference: https://google.github.io/styleguide/shellguide.html#s1.2-whe... - If you are writing a script that is more than 100 lines long, or that uses non-straightforward control flow logic, you should rewrite it in a more structured language now. Bear in mind that scripts grow. Rewrite your script early to avoid a more time-consuming rewrite at a later date. - When assessing the com…

Cute, but a few years back $client was an early-ish adopter of Anthos Service Mesh (Google-managed(ish) Istio for GKE), and to install it we had to run a Bash script that was over 1,000 lines long.

When we questioned the Google engineer assigned to support us, he snickered and said "you can trust it".

Re: Just Use Curl

#142

The author could benefit from some research into user centered design. CLI is notorious for poor discoverability and consistency, two halmarks of GUI (at least 20 years ago; these days less focus is put on these elements). Humans are very not good at remembering command line flags but great at looking at then manipulating a screen that shows fields for all the flags.

That may be true for a tool that's not used often. For professional tooling, muscle memory and response time beat discoverability any day of the week.

GUIs are (usually) slow and break the flow. They cater for the bottom of the pile of users, in detriment of the top.

Re: Just Use Curl

#143
Is curl ever going to have a mature /sane way to handle silent output? I seem to have to redirect 2>&1 and other -o- options. It’s annoying. Always has been.

Re: Just Use Curl

#144
post #137

Earlier quoted context omitted.

I use emacs restclient all the time. I have requests saved in my orgmode notes that I can run with a simple C-c C-c. It's great.

You're using this as well? https://github.com/alf/ob-restclient.el

Ya I babel all sorts of things. I have sql queries saved in my notes for things like creating a user after I reset the project locally. Common rest queries. I create an orgmode heading for every ticket I pick up and often end up with rest and/or sql queries littered in the notes for testing and development and I can run them right from the notes and when I'm done with the ticket I can just copy/paste them into the pull request description to fill out the manual test steps for those reviewing.

Re: Just Use Curl

#145

I might get lit on fire for this, but I don't find manpages very easy to use. If want to quickly remember an option or argument order, I am met with a wall of text. Does anyone have tips for how to make it more useful? Maybe I could grep better for options? For example in the link, the author lists out common curl commands like making a POST request or adding a header. If you tried to look through the manpage for thi…

> Does anyone have tips for how to make it more useful? Maybe I could grep better for options? For example in the link, the author lists out common curl commands like making a POST request or adding a header. If you tried to look through the manpage for this, this would take a long time. You can search a man page by pressing the '/' key, typing in what you want, and pressing 'enter'. 'n' jumps to the next instance of…

Okay good point… I still think common usage examples would be nice because I don’t even know what some commands are capable of

Re: Just Use Curl

#146
post #69

Does anyone have suggestions for when I need to use bearer auth and the token is super long? With curl I end up finding the command becomes hard to read, even taking advantage of backslashes. With Postman, it tidily hides the token out of the way on a separate tab and gets out of my way.

What i do is assign the token to a variable. I typically copy the secret to my clipboard, and then use the pbpaste command in macos terminal when assigning it to avoid secrets in my command history.

I don't know how consistent this is across shells, but at least in bash putting a space before the command keeps it out of the history:

  $ ONE=1
  $  TWO=2
  $ echo $ONE $TWO
  1 2
  $ history | tail -n 4
   2002  clear
   2003  ONE=1
   2004  echo $ONE $TWO
   2005  history | tail -n 4

Re: Just Use Curl

#148
post #64

I might get lit on fire for this, but I don't find manpages very easy to use. If want to quickly remember an option or argument order, I am met with a wall of text. Does anyone have tips for how to make it more useful? Maybe I could grep better for options? For example in the link, the author lists out common curl commands like making a POST request or adding a header. If you tried to look through the manpage for thi…

Add this to the end of .bashrc function cheat() { curl cht.sh/$1 } Then in terminal you can use the following to see the examples: $ cheat curl

Holy shit this website is insanely helpful. Many thanks!

Re: Just Use Curl

#149

I might get lit on fire for this, but I don't find manpages very easy to use. If want to quickly remember an option or argument order, I am met with a wall of text. Does anyone have tips for how to make it more useful? Maybe I could grep better for options? For example in the link, the author lists out common curl commands like making a POST request or adding a header. If you tried to look through the manpage for thi…

I find man pages to be useful when I’m already familiar with the command or topic. For long man pages, I usually get on fine by `grep`ing for relevant key-words.

I agree that they are daunting and not so helpful for users who are new to the command or topic. They usually lack a quick-start guide with examples that give the user a starting point to build upon.

Anyhow, after hearing about `tldr` for close to a decade, your comment inspired me to install it. When I tried running `tldr curl`, I was delighted to learn something new and useful:

    # Resolve a hostname to a custom IP address, with verbose output (similar to editing the /etc/hosts file for custom DNS resolution):
    curl --verbose --resolve example.com:80:127.0.0.1 http://example.com

Re: Just Use Curl

#150

Earlier quoted context omitted.

> Does anyone have tips for how to make it more useful? Maybe I could grep better for options? For example in the link, the author lists out common curl commands like making a POST request or adding a header. If you tried to look through the manpage for this, this would take a long time. You can search a man page by pressing the '/' key, typing in what you want, and pressing 'enter'. 'n' jumps to the next instance of…

Okay good point… I still think common usage examples would be nice because I don’t even know what some commands are capable of

Some man pages are better than others. OpenBSD's man pages are usually very good. Linux's man pages sometimes are so bare that they're worse than if they weren't there at all.
Post reply on HN