spf13/cobra
View on GitHub ↗ ★ 44,740 Go
A Commander for modern Go CLI interactions
42 mentions on Hacker News by 40 people: 7 stories, 35 comments · first 2015-01-03 · latest 2026-01-14
20082026
-
…v1.1.0 github.com/charmbracelet/log v0.4.2 github.com/mattn/go-sqlite3 v1.14.22 github.com/spf13/cobra v1.10.1 )
comment by cloverich · 2025-10-06 · in Show HN: Write It Down – Personal finance tracker -
Here is one of your empty argument being thrown away instead of respected bugs: * https://github.com/spf13/cobra/blob/6dec1ae26659a130bdb4c985... I could explain the single-quote argument quoting error if you were running it on Windows.…
comment by JdeBP · 2025-06-19 · in Fang, the CLI Starter Kit -
…featured CLI builder package like cobra has just a few transitive deps and gorilla/mux has none: https://github.com/spf13/cobra/blob/main/go.sum https://github.com/gorilla/mux/blob/main/go.mod If I compare that with express.js or commander…
comment by tuckerman · 2025-05-11 · in Leaving Google -
Cobra https://github.com/spf13/cobra uses https://github.com/spf13/pflag , which supports GNU style flags. Cobra has been developed for many years now and has a ton of additional features, like automatically generating the autocompletions…
comment by latchkey · 2025-03-23 · in argp: GNU-style command line argument parser for Go -
…using one of the libraries listed here : https://bloomberg.github.io/stricli/blog/intro (TS/JS) or https://github.com/spf13/cobra (Go) with stub implementations for commands. The main problem for me is that defining the CLI in a JSON file…
comment by pmdfgy · 2025-02-27 · in Show HN: Protostar – A CLI Prototyping Tool -
I use https://github.com/spf13/cobra religiously for this kind of thing - it handles all the annoying corner cases of parsing flags, and also has an intuitive notion of subcommands (with basic usage/help text generated) for picking which…
comment by GeneralMayhem · 2024-03-27 · in Scripts should be written using the project main language -
…comes with so many best practices already packaged like autocompletions, help texts etc. etc. [1]: https://github.com/spf13/cobra
comment by pmig · 2024-02-06 · in Command line interface guidelines (2021) -
…- test assertion library - https://github.com/rs/zerolog - logging - https://github.com/spf13/cobra - CLI framework FWIW, I just lifted all the tools we use for https://github.com/authzed/spicedb We've also written some custom
comment by jzelinskie · 2023-05-23 · in How to start a Go project in 2023 -
…how others did theirs: - https://cs.github.com/?scopeName=All+repos&scope=&q=github.c... [0]: https://github.com/spf13/cobra
comment by ezekg · 2023-02-28 · in Ask HN: Why is there no specification for Command Line Interfaces? -
…are in that Awesome Terminals round-up linked in the article). The Cobra library is a huge one: https://github.com/spf13/cobra Other stuff worth a look includes: Tmux: https://github.com/tmux/tmux Kitty: https://github.com/kovidgoyal/kitty…
comment by klint · 2022-09-13 · in A look at various trends shaping the future of the command line -
...but that fifth dependency makes all the difference! $ go mod init foo && go get github.com/spf13/cobra && wc -l go.sum 758 go.sum $ go mod init foo && go get github.com/muesli/coral && wc -l go.sum 10 go.sum (Number of lines in go.sum…
comment by racingmars · 2022-02-04 · in Coral, a Cobra fork with nearly all its features, but only 4 dependencies -
Right but that last one is the problem... https://github.com/muesli/coral/blob/master/go.sum https://github.com/spf13/cobra/blob/master/go.sum
comment by jjnoakes · 2022-02-04 · in Coral, a Cobra fork with nearly all its features, but only 4 dependencies -
…replacement for Cobra in existing projects, just let gofmt do the heavy lifting for you: gofmt -w -r '"github.com/spf13/cobra" -> "github.com/muesli/coral"' . gofmt -w -r '"github.com/spf13/cobra/doc" -> "github.com/muesli/coral/doc"' .…
comment by CraigJPerry · 2022-02-04 · in Coral, a Cobra fork with nearly all its features, but only 4 dependencies -
…better job with the title here. See: - [0] https://github.com/muesli/coral/blob/master/go.mod - [1] https://github.com/spf13/cobra/blob/master/go.mod
comment by bigdubs · 2022-02-04 · in Coral, a Cobra fork with nearly all its features, but only 4 dependencies -
https://github.com/spf13/cobra seems to be the most comprehensive, but honourable mentions go to all of the rest.
comment by gjvc · 2022-01-17 · in Ask HN: What libraries does go have for building interactive shells? -
…library should provide basic functionality (in most general areas), but not very advanced one. [1] https://github.com/spf13/cobra
comment by megumax · 2021-11-05 · in Embedded malware in RC (NPM package) -
Cobra ( https://github.com/spf13/cobra ), which is a pretty popular library for Go CLI applications, behaves more like classical GNU tools. It also offers usage/help autogeneration and autocompletion for popular shells. Not sure about the…
comment by hnjst · 2021-04-09 · in Why do long options start with two dashes? (2019) -
…revenko/tsukae/cmd.glob..func4(0x135df20, 0xc00005c8b0, 0x0, 0x1) /Users/pww/tsukae/cmd/commands.go:88 +0x1bf github.com/spf13/cobra.(*Command).execute(0x135df20, 0xc00005c8a0, 0x1, 0x1, 0x135df20, 0xc00005c8a0)…
comment by PeterWhittaker · 2021-02-27 · in Show HN: Unix tool that visualizes shell commands usage -
…go get -d ./... go: downloading github.com/inconshreveable/mousetrap v1.0.0 % go run main.go o: downloading github.com/spf13/cobra v1.1.3 go: downloading github.com/gizak/termui/v3 v3.1.0 go: downloading github.com/mattn/go-runewidth…
comment by PeterWhittaker · 2021-02-26 · in Show HN: Unix tool that visualizes shell commands usage -
Most popular Go CLIs use https://github.com/spf13/cobra i.e. Docker / K8s / OpenFaaS and similar
comment by alexellisuk · 2020-11-11 · in Five Keys to create a killer CLI in Go -
…wheel or trying to remember some weird non-standard quirks. [1] https://github.com/spf13/pflag [2] https://github.com/spf13/cobra [3] https://github.com/spf13/viper
comment by programd · 2020-08-01 · in Conventions for Command Line Options -
…choice for prototyping. I actually started learning Go with CLI applications. I have found that https://github.com/spf13/cobra tends to be one of the better CLI helpers you can get into but https://github.com/jpillora/opts is one I have…
comment by boyter · 2020-05-27 · in Diving into Go by building a CLI application -
Since everyone else is throwing out recommendations I personally think https://github.com/spf13/cobra is the best CLI templating system, especially because of how well it pairs with https://github.com/spf13/viper . Large projects like Hugo…
comment by dashwav · 2020-05-27 · in Diving into Go by building a CLI application -
…you mean. Go's spf13/cobra will soon have working zsh/bash/fish/powershell autocomplete generation! https://github.com/spf13/cobra/pull/1070
comment by DelightOne · 2020-05-21 · in OpenAutoComplete: Shell-agnostic, cross-platform autocomplete specification -
This is what you're looking for: https://github.com/spf13/cobra They are many libs that do that, you probably didn't search very long ...
comment by Thaxll · 2019-11-16 · in The Value in Go’s Simplicity -
…I've needed via a reasonable API, but I'll admin I'm not fussy about CLI utility behavior. [0] https://github.com/spf13/cobra
comment by andrewksl · 2019-11-16 · in The Value in Go’s Simplicity -
Always interesting to see what CLI library is used. Looks like another feather in the cap of https://github.com/spf13/cobra . I would love to hear why they chose cobra over something like https://github.com/urfave/cli
comment by SomaticPirate · 2019-11-05 · in Stripe CLI -
…( https://github.com/stripe/stripe-cli ), it seems they are using the GO CLI framework Cobra ( https://github.com/spf13/cobra ).
comment by bckmn · 2019-11-05 · in Stripe CLI -
…nicely expand based on main arguments with flags. Also, setting defaults is a joy. For CLIs - https://github.com/spf13/cobra . However, will definitely try out Docli whenever I start building something new :)
comment by deforciant · 2019-03-20 · in Docli – A declarative language for command-line interfaces in Go -
Seems like Cobra is pretty well established in this space - https://github.com/spf13/cobra Tho admittedly it works in reverse; it generates the doc/help info rather than parsing it into an AST. It addresses the “boilerplate” issue with…
comment by thanatos_dem · 2019-03-20 · in Docli – A declarative language for command-line interfaces in Go -
Are you familiar with https://github.com/spf13/cobra ? It's used by a few heavy hitters (kubernetes's kubectl) and it provides you a bit of help with bash completion: https://github.com/spf13/cobra/blob/master/bash_completions.... I just…
comment by pgwhalen · 2018-08-27 · in How to Enable Autocomplete in Mac Terminal -
…makes this possible like Click[1] for Python or cobra[2] for Go. [1] http://click.pocoo.org/6/ [2] https://github.com/spf13/cobra
comment by Walkman · 2018-08-01 · in GUIs Considered Harmful (1992) -
…sure this uses cobra, but you could start easily by writing basic CLI tools using cobra[0] [0] - https://github.com/spf13/cobra
comment by vthallam · 2018-05-31 · in WTF: A personal information dashboard for your terminal -
Go has been a game changer for me also. There is also a very good package https://github.com/spf13/cobra that can make the development of complex CLIs easier.
comment by yannis · 2016-10-11 · in Exploring CLI Best Practices -
…( http://golang.org/pkg/flag/ ) if you just need flag parsing. I've also heard good things about https://github.com/spf13/cobra and https://github.com/codegangsta/cli .
comment by motter · 2015-01-03 · in GitHub's “hub” tool rewritten in Golang