charmbracelet/fang
{ "createdAt": "2024-11-22T19:35:05Z", "defaultBranch": "main", "description": "The CLI starter kit", "fullName": "charmbracelet/fang", "homepage": "", "language": "Go", "name": "fang", "pushedAt": "2025-11-10T20:43:32Z", "stargazersCount": 1776, "topics": [], "updatedAt": "2025-11-26T14:39:29Z", "url": "https://github.com/charmbracelet/fang"}
The CLI starter kit. A small, experimental library for batteries-included [Cobra][cobra] applications.
Features
Section titled “Features”- Fancy output: fully styled help and usage pages
- Fancy errors: fully styled errors
- Automatic
--version: set it to the [build info][info], or a version of your choice - Manpages: Adds a hidden
mancommand to generate manpages using [mango][][^1] - Completions: Adds a
completioncommand to generate shell completions - Themeable: use the built-in theme, or make your own
- UX: Silent
usageoutput (help is not shown after a user error)
[info] !: https://pkg.go.dev/runtime/debug#BuildInfo [cobra] !: https://github.com/spf13/cobra [mango] !: https://github.com/muesli/mango
[^1] !: Default cobra man pages generates one man page for each command. This is generally fine for programs with a lot of sub commands, like git, but its an overkill for smaller programs. Mango also uses roff directly instead of converting from markdown, so it should render better looking man pages.
To use it, invoke fang.Execute passing your root *cobra.Command:
package main
import ( "context" "os"
"github.com/charmbracelet/fang" "github.com/spf13/cobra")
func main() { cmd := &cobra.Command{ Use: "example", Short: "A simple example program!", } if err := fang.Execute(context.Background(), cmd); err != nil { os.Exit(1) }}That’s all there is to it!
Contributing
Section titled “Contributing”See [contributing][contribute].
[contribute] !: https://github.com/charmbracelet/fang/contribute
Feedback
Section titled “Feedback”We’d love to hear your thoughts on this project. Feel free to drop us a note!
License
Section titled “License”Part of Charm.
Charm热爱开源 • Charm loves open source
