I am curious what people reach for when writing CLIs these days; specifically what language, libraries (if any), and why?<p>By CLI, I mean any executable program or script like git that supports commands, sub-commands, and POSIX-style flags.<p>I mostly work in Go, and have been happy with the standard library[1] or Cobra[2]. I also write a lot of shell scripts.<p>I thought it would be interesting to see some other approaches.<p>[1]: https://pkg.go.dev/flag
[2]: https://cobra.dev
I use a lot of CLI tools, but haven't written many for myself. Mostly, aliases/functions and some scripts in Bash/Python.<p>1) Extract details for command options from man/help: <a href="https://github.com/learnbyexample/command_help/blob/master/ch" rel="nofollow">https://github.com/learnbyexample/command_help/blob/master/c...</a><p>2) cut-like syntax for field manipulations with regexp, negative indexing, etc: <a href="https://github.com/learnbyexample/regexp-cut/blob/main/rcut" rel="nofollow">https://github.com/learnbyexample/regexp-cut/blob/main/rcut</a><p>3) Simple calculator using python syntax: <a href="https://learnbyexample.github.io/practice_python_projects/calculator/calc_py_cli.html" rel="nofollow">https://learnbyexample.github.io/practice_python_projects/ca...</a>
Sorry. Unless I'm missing something completely, I have to ask: 'Why would you bother to reinvent the wheel?'<p>If you want something like bash, just use bash. If you want a CLI in a GUI environment, just use 'terminal', or'xterm' or similar.<p>If you're talking about apps that run in a CLI, then the world is your oyster. Use whatever you need depending on what the app requires.<p>If you're talking about what language to use, then just use which ever language that you're comfortable with that can/will produce a text output.
Oclif is pretty nice for NodeJS, we use it for <a href="https://github.com/matanolabs/matano" rel="nofollow">https://github.com/matanolabs/matano</a> . <a href="https://github.com/charmbracelet/bubbletea" rel="nofollow">https://github.com/charmbracelet/bubbletea</a> looks really beautiful, if you use Go.
I made fx at Flexport, which hosted many of our CLI tools. I liked it a lot, so I made one for myself when I left: <a href="https://github.com/jathu/fx" rel="nofollow">https://github.com/jathu/fx</a><p>fx is a workspace tool manager. It allows you to create consistent, discoverable, language-neutral and developer friendly command line tools.
I use Go and Cobra for my business’s CLI [0]. I like it. Go is pretty unmatched for CLIs.<p>[0]: <a href="https://github.com/keygen-sh/keygen-cli" rel="nofollow">https://github.com/keygen-sh/keygen-cli</a>