News for hackers. Stuff that matters.

Ask HN: What do you use to make CLIs?

I am curious what people reach for when writing CLIs these days; specifically what language, libraries (if any), and why?

By CLI, I mean any executable program or script like git that supports commands, sub-commands, and POSIX-style flags.

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.

I thought it would be interesting to see some other approaches.

[1]: https://pkg.go.dev/flag [2]: https://cobra.dev

( 14 comments | 11 points | on HN )
Re:Ask HN: What do you use to make CLIs? by asicsp on Friday August 26, 2022 @11:05AM (#32608466)
I use a lot of CLI tools, but haven't written many for myself. Mostly, aliases/functions and some scripts in Bash/Python.

1) Extract details for command options from man/help: https://github.com/learnbyexample/command_help/blob/master/c...

2) cut-like syntax for field manipulations with regexp, negative indexing, etc: https://github.com/learnbyexample/regexp-cut/blob/main/rcut

3) Simple calculator using python syntax: https://learnbyexample.github.io/practice_python_projects/ca...

Re:Ask HN: What do you use to make CLIs? by simonblack on Friday August 26, 2022 @09:54PM (#32614816)
Sorry. Unless I'm missing something completely, I have to ask: 'Why would you bother to reinvent the wheel?'

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.

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.

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.

Re:Ask HN: What do you use to make CLIs? by wizwit999 on Friday August 26, 2022 @11:35AM (#32608841)
Oclif is pretty nice for NodeJS, we use it for https://github.com/matanolabs/matano . https://github.com/charmbracelet/bubbletea looks really beautiful, if you use Go.
Re:Ask HN: What do you use to make CLIs? by jathu on Friday August 26, 2022 @11:55AM (#32609069)
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: https://github.com/jathu/fx

fx is a workspace tool manager. It allows you to create consistent, discoverable, language-neutral and developer friendly command line tools.

Re:Ask HN: What do you use to make CLIs? by stop50 on Friday August 26, 2022 @10:48AM (#32608239)
For python i like the builtin argparse.
Re:Ask HN: What do you use to make CLIs? by ezekg on Friday August 26, 2022 @01:04PM (#32610090)
I use Go and Cobra for my business’s CLI [0]. I like it. Go is pretty unmatched for CLIs.

[0]: https://github.com/keygen-sh/keygen-cli

Re:Ask HN: What do you use to make CLIs? by FujiApple on Friday August 26, 2022 @10:24AM (#32607928)
Re:Ask HN: What do you use to make CLIs? by pez_dev on Friday August 26, 2022 @03:12PM (#32611526)
Mostly go whenever shell scripts are not enough.

Check out the libraries from charm (charm.sh). They really make the command line glamorous!

Re:Ask HN: What do you use to make CLIs? by marek_leisk2 on Friday August 26, 2022 @12:14PM (#32609298)
Re:Ask HN: What do you use to make CLIs? by IceMetalPunk on Friday August 26, 2022 @12:07PM (#32609218)
I'm a JavaScript dev, so I tend to go for Node with Inquirer + Commander.
Re:Ask HN: What do you use to make CLIs? by linkdd on Friday August 26, 2022 @11:11AM (#32608551)
Rust + Clap

Go + Cobra

Python + Click

Re:Ask HN: What do you use to make CLIs? by drakonka on Friday August 26, 2022 @11:58AM (#32609105)
I usually turn to Go for all of my CLI needs.
Re:Ask HN: What do you use to make CLIs? by zem on Monday August 29, 2022 @01:35AM (#32635084)
mostly ruby or python, though I would like to explore ocaml more for the purpose
Re:Ask HN: What do you use to make CLIs? by rurban on Saturday August 27, 2022 @02:02AM (#32616195)
95% C (with occasional Windows quirks),

5% shell.

previously lots of perl