Re:Bash code generator for command-line arguments
by xurukefi on Friday October 02, 2020 @08:33AM
(#24661928)
As soon as as the cli becomes non-trivial I switch to python and use docopt for that (really cool module btw.). Pipelining processes is not as idiomatic in Python as it is in Bash though, but everything is better than getopts. I'd rather decapitate myself with a teaspoon than using getopts.
[ Parent
| on HN ]
Re:Bash code generator for command-line arguments
by vlovich123 on Friday October 02, 2020 @10:30AM
(#24662965)
Yeah, I’m kind of shocked to see so many masochists in this thread. Built-in subprocess is nice and all but I’ve had a lot of joy using https://amoffat.github.io/sh/ to do the work (and the maintainer is super responsive). I sometimes don’t have the flexibility to have external dependencies but I’d use it everywhere if Python just folded it into the default library.
Re:Bash code generator for command-line arguments
by OJFord on Friday October 02, 2020 @09:56AM
(#24662620)
Docopt exists (now, think it was originally python) for many languages including bash [0] (or perhaps it's POSIX, haven't checked).
I like it too, not least because I can use ~the same thing in multiple languages and not have to remind myself how the arg parser for language X works each time.