<img width="485" alt="Charm Fang" src="https://github.com/user-attachments/assets/3f34ea01-3750-4760-beb2-a1b700e110f5">
<a href="https://github.com/charmbracelet/fang/releases"><img src="https://img.shields.io/github/release/charmbracelet/fang.svg" alt="Latest Release"></a>
<a href="https://pkg.go.dev/github.com/charmbracelet/fang?tab=doc"><img src="https://godoc.org/github.com/charmbracelet/fang?status.svg" alt="GoDoc"></a>
<a href="https://github.com/charmbracelet/fang/actions"><img src="https://github.com/charmbracelet/fang/workflows/build/badge.svg" alt="Build Status"></a>
The CLI starter kit. A small, experimental library for batteries-included Cobra applications.
<img width="859" alt="The Charm Fang mascot and title treatment" src="https://github.com/user-attachments/assets/5c35e1fa-9577-4f81-a879-3ddb4d4a43f0" />
--version: set it to the build info, or a version of your choiceman command to generate manpages using
mango[^1]completion command to generate shell completionsusage output (help is not shown after a user error)[^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!
See contributing.
We’d love to hear your thoughts on this project. Feel free to drop us a note!
Part of Charm.
Charm热爱开源 • Charm loves open source