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. ▲ 1
    Show HN: Convert Go to Rust
    story by KingOfCoders · 2026-01-14 · 0 comments
  2. …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 )
  3. 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
  4. …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
  5. 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…
  6. …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…
  7. ▲ 2
    Show HN: CREV – A Go-based CLI tool for AI code reviews and codebase exports
    story by elpookie · 2024-10-06 · 0 comments
  8. 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…
  9. …comes with so many best practices already packaged like autocompletions, help texts etc. etc. [1]: https://github.com/spf13/cobra
  10. …- 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
  11. …how others did theirs: - https://cs.github.com/?scopeName=All+repos&scope=&q=github.c... [0]: https://github.com/spf13/cobra
  12. …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…
  13. ▲ 4
    Cobra v1.5.0 Is Released
    story by c4pt0r · 2022-06-21 · 0 comments
  14. ...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…
  15. 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
  16. …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"' .…
  17. …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
  18. https://github.com/spf13/cobra seems to be the most comprehensive, but honourable mentions go to all of the rest.
  19. ▲ 2
    Ask HN: What libraries does go have for building interactive shells?
    story by gjvc · 2022-01-16 · 2 comments
  20. …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)
  21. ▲ 1
    cobra: A commander for modern Go CLI interactions
    story by ducktective · 2021-10-01 · 0 comments
  22. 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…
  23. …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)…
  24. …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…
  25. 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
  26. …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
  27. …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…
  28. 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…
  29. …you mean. Go's spf13/cobra will soon have working zsh/bash/fish/powershell autocomplete generation! https://github.com/spf13/cobra/pull/1070
  30. 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
  31. …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
  32. 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
  33. …( 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
  34. …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 :)
  35. 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…
  36. 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
  37. …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)
  38. …sure this uses cobra, but you could start easily by writing basic CLI tools using cobra[0] [0] - https://github.com/spf13/cobra
  39. ▲ 3
    Cobra: A Commander for Modern Go CLI Interactions
    story by kiyanwang · 2018-03-02 · 0 comments
  40. 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
  41. ▲ 2
    Cobra: Build Modern CLI Apps in Go
    story by travjones · 2016-04-18 · 0 comments
  42. …( 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 .