TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What do you use to make CLIs?

11 点作者 mmwtsn超过 2 年前
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:&#x2F;&#x2F;pkg.go.dev&#x2F;flag [2]: https:&#x2F;&#x2F;cobra.dev

14 条评论

asicsp超过 2 年前
I use a lot of CLI tools, but haven&#x27;t written many for myself. Mostly, aliases&#x2F;functions and some scripts in Bash&#x2F;Python.<p>1) Extract details for command options from man&#x2F;help: <a href="https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;command_help&#x2F;blob&#x2F;master&#x2F;ch" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;command_help&#x2F;blob&#x2F;master&#x2F;c...</a><p>2) cut-like syntax for field manipulations with regexp, negative indexing, etc: <a href="https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;regexp-cut&#x2F;blob&#x2F;main&#x2F;rcut" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;regexp-cut&#x2F;blob&#x2F;main&#x2F;rcut</a><p>3) Simple calculator using python syntax: <a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;practice_python_projects&#x2F;calculator&#x2F;calc_py_cli.html" rel="nofollow">https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;practice_python_projects&#x2F;ca...</a>
simonblack超过 2 年前
Sorry. Unless I&#x27;m missing something completely, I have to ask: &#x27;Why would you bother to reinvent the wheel?&#x27;<p>If you want something like bash, just use bash. If you want a CLI in a GUI environment, just use &#x27;terminal&#x27;, or&#x27;xterm&#x27; or similar.<p>If you&#x27;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&#x27;re talking about what language to use, then just use which ever language that you&#x27;re comfortable with that can&#x2F;will produce a text output.
wizwit999超过 2 年前
Oclif is pretty nice for NodeJS, we use it for <a href="https:&#x2F;&#x2F;github.com&#x2F;matanolabs&#x2F;matano" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;matanolabs&#x2F;matano</a> . <a href="https:&#x2F;&#x2F;github.com&#x2F;charmbracelet&#x2F;bubbletea" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;charmbracelet&#x2F;bubbletea</a> looks really beautiful, if you use Go.
jathu超过 2 年前
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:&#x2F;&#x2F;github.com&#x2F;jathu&#x2F;fx" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jathu&#x2F;fx</a><p>fx is a workspace tool manager. It allows you to create consistent, discoverable, language-neutral and developer friendly command line tools.
stop50超过 2 年前
For python i like the builtin argparse.
ezekg超过 2 年前
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:&#x2F;&#x2F;github.com&#x2F;keygen-sh&#x2F;keygen-cli" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;keygen-sh&#x2F;keygen-cli</a>
FujiApple超过 2 年前
Rust + Clap: <a href="https:&#x2F;&#x2F;github.com&#x2F;clap-rs&#x2F;clap" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;clap-rs&#x2F;clap</a>
pez_dev超过 2 年前
Mostly go whenever shell scripts are not enough.<p>Check out the libraries from charm (charm.sh). They really make the command line glamorous!
marek_leisk2超过 2 年前
<a href="https:&#x2F;&#x2F;typer.tiangolo.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;typer.tiangolo.com&#x2F;</a>
IceMetalPunk超过 2 年前
I&#x27;m a JavaScript dev, so I tend to go for Node with Inquirer + Commander.
linkdd超过 2 年前
Rust + Clap<p>Go + Cobra<p>Python + Click
drakonka超过 2 年前
I usually turn to Go for all of my CLI needs.
zem超过 2 年前
mostly ruby or python, though I would like to explore ocaml more for the purpose
rurban超过 2 年前
95% C (with occasional Windows quirks),<p>5% shell.<p>previously lots of perl