Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
cli
✓ github.com/mitchellh/cli
Create a CLI with subcommands
package main
import (
"github.com/mitchellh/cli"
)
func main() {
c := cli.NewCLI("app", "1.0.0")
c.Args = os.Args[1:]
c.Commands = map[string]cli.CommandFactory{
"hello": func() (cli.Command, error) {
return &HelloCommand{}, nil
},
}
exitCode, err := c.Run()
if err != nil {
panic(err)
}
os.Exit(exitCode)
}
type HelloCommand struct{}
func (h *HelloCommand) Help() string { return "prints hello" }
func (h *HelloCommand) Run(args []string) int {
fmt.Println("Hello")
return 0
}
func (h *HelloCommand) Synopsis() string { return "prints hello" }
Debug
Known issues
No known issues recorded.
Upgrade
Version history
1.1.5latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.