Hacker GitHub

← All repos

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

Mentions per year 42 mentions · busiest year 2022 (8)
20082026
  1. …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 )
  2. 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
  3. …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
  4. 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…
  5. …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…
  6. 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…
  7. …comes with so many best practices already packaged like autocompletions, help texts etc. etc. [1]: https://github.com/spf13/cobra
  8. …- 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
  9. …how others did theirs: - https://cs.github.com/?scopeName=All+repos&scope=&q=github.c... [0]: https://github.com/spf13/cobra
  10. …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…
  11. ...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…
  12. 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
  13. …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"' .…
  14. …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
  15. https://github.com/spf13/cobra seems to be the most comprehensive, but honourable mentions go to all of the rest.
  16. …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)
  17. 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…
  18. …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)…
  19. …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…
  20. 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
  21. …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
  22. …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…
  23. 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…
  24. …you mean. Go's spf13/cobra will soon have working zsh/bash/fish/powershell autocomplete generation! https://github.com/spf13/cobra/pull/1070
  25. 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
  26. …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
  27. 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
  28. …( 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
  29. …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 :)
  30. 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…
  31. 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
  32. …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)
  33. …sure this uses cobra, but you could start easily by writing basic CLI tools using cobra[0] [0] - https://github.com/spf13/cobra
  34. 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
  35. …( 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 .