https://github.com/charmbracelet/fang
The CLI starter kit
https://github.com/charmbracelet/fang
Last synced: 4 months ago
JSON representation
The CLI starter kit
- Host: GitHub
- URL: https://github.com/charmbracelet/fang
- Owner: charmbracelet
- License: mit
- Created: 2024-11-22T19:35:05.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-06-26T18:08:01.000Z (4 months ago)
- Last Synced: 2025-06-26T18:32:50.851Z (4 months ago)
- Language: Go
- Homepage:
- Size: 453 KB
- Stars: 1,186
- Watchers: 2
- Forks: 18
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-repositories - charmbracelet/fang - The CLI starter kit (Go)
README
# Fang
The CLI starter kit. A small, experimental library for batteries-included [Cobra][cobra] applications.
## 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 `man` command to generate _manpages_ using
[mango][][^1]
- **Completions**: Adds a `completion` command to generate shell completions
- **Themeable**: use the built-in theme, or make your own
- **UX**: Silent `usage` output (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.
## Usage
To use it, invoke `fang.Execute` passing your root `*cobra.Command`:
```go
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
See [contributing][contribute].
[contribute]: https://github.com/charmbracelet/fang/contribute
## Feedback
We’d love to hear your thoughts on this project. Feel free to drop us a note!
- [Twitter](https://twitter.com/charmcli)
- [Discord](https://charm.sh/chat)
- [The Fediverse](https://mastodon.social/@charmcli)
## License
[MIT](https://github.com/charmbracelet/gum/raw/main/LICENSE)
---
Part of [Charm](https://charm.sh).
Charm热爱开源 • Charm loves open source
