4 ms·
I think people are underestimating the power of `bash+curl+jq`. In pretty much every scenario where I want to consume an API, I just fire up my vim+shellcheck+s
by ducktective 5y ago
I think people are underestimating the power of `bash+curl+jq`. In pretty much every scenario where I want to consume an API, I just fire up my vim+shellcheck+shfmt setup, split my logic into functions (using `local` for private variable, mind you), then just spam `get_endpoint | jq filter`s in a `getopts` loop, and bam, suddenly you have a clean and concise CLI.
Granted, Bash is quirky. So I should say I program in bash+shellcheck not just Bash.
And Jq. Jq is a functional programming language in itself! I do regex or string mangling inside jq filters.
Why should I use Python over this? The moment you want a clean and cool feature that Python has over Bash+jq, you should incorporate third party libraries. And adding just one non-std lib, means you have to resort to `virtual env`. And why not adding also `click` or `requests` or .. and now you have ~10 moving dependencies. Let's not talk about Python's subtle differences between versions.
Compare it to Bash-as-glue-of-unix-tools approach. You want image processing? Just use `imagemagick`. You want web scraping? `pup` is your friend.
ProTip: do `my_command || exit 1` if my_command is bound to fail. Or `if ! my_command; then printf >&2 "[ERROR] reasons"; exit 4 fi` for more elaborate exception-handling.
- mistrial9 5y agothat exact sequence is possible in lots of desktop environments, with their own list and exception handling. Many people here show that the result of the fast (and fun?) steps result in something that other people can't change much, and have a lot of non-obvious footguns. Last, if you like it, no judgement from me about that!
- brainzap 5y agothis is a fair response, the curse of knowledge is real