Fang
The CLI starter kit. A small, experimental library for batteries-included Cobra applications.
Features
Fancy output : fully styled help and usage pages
: fully styled help and usage pages Fancy errors : fully styled errors
: fully styled errors Automatic --version : set it to the build info, or a version of your choice
: set it to the build info, or a version of your choice Manpages : Adds a hidden man command to generate manpages using mango 1
: Adds a hidden command to generate manpages using mango Completions : Adds a completion command to generate shell completions
: Adds a command to generate shell completions Themeable : use the built-in theme, or make your own
: use the built-in theme, or make your own UX: Silent usage output (help is not shown after a user error)
Usage
To use it, invoke fang.Execute passing your root *cobra.Command :
package main import ( "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 . TODO (), cmd ); err != nil { os . Exit ( 1 ) } }
That's all there is to it!
Contributing
See contributing.
Feedback
We’d love to hear your thoughts on this project. Feel free to drop us a note!
License
MIT
Part of Charm.
Charm热爱开源 • Charm loves open source