|
|
|
@ -90,7 +90,62 @@ func ExampleApp_Run_subcommand() {
|
|
|
|
|
// Hello, Jeremy
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ExampleApp_Run_help() {
|
|
|
|
|
func ExampleApp_Run_appHelp() {
|
|
|
|
|
// set args for examples sake
|
|
|
|
|
os.Args = []string{"greet", "help"}
|
|
|
|
|
|
|
|
|
|
app := NewApp()
|
|
|
|
|
app.Name = "greet"
|
|
|
|
|
app.Version = "0.1.0"
|
|
|
|
|
app.Description = "This is how we describe greet the app"
|
|
|
|
|
app.Authors = []Author{
|
|
|
|
|
{Name: "Harrison", Email: "harrison@lolwut.com"},
|
|
|
|
|
{Name: "Oliver Allen", Email: "oliver@toyshop.com"},
|
|
|
|
|
}
|
|
|
|
|
app.Flags = []Flag{
|
|
|
|
|
StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
|
|
|
|
|
}
|
|
|
|
|
app.Commands = []Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "describeit",
|
|
|
|
|
Aliases: []string{"d"},
|
|
|
|
|
Usage: "use it to see a description",
|
|
|
|
|
Description: "This is how we describe describeit the function",
|
|
|
|
|
Action: func(c *Context) error {
|
|
|
|
|
fmt.Printf("i like to describe things")
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
|
// Output:
|
|
|
|
|
// NAME:
|
|
|
|
|
// greet - A new cli application
|
|
|
|
|
//
|
|
|
|
|
// USAGE:
|
|
|
|
|
// greet [global options] command [command options] [arguments...]
|
|
|
|
|
//
|
|
|
|
|
// VERSION:
|
|
|
|
|
// 0.1.0
|
|
|
|
|
//
|
|
|
|
|
// DESCRIPTION:
|
|
|
|
|
// This is how we describe greet the app
|
|
|
|
|
//
|
|
|
|
|
// AUTHORS:
|
|
|
|
|
// Harrison <harrison@lolwut.com>
|
|
|
|
|
// Oliver Allen <oliver@toyshop.com>
|
|
|
|
|
//
|
|
|
|
|
// COMMANDS:
|
|
|
|
|
// describeit, d use it to see a description
|
|
|
|
|
// help, h Shows a list of commands or help for one command
|
|
|
|
|
//
|
|
|
|
|
// GLOBAL OPTIONS:
|
|
|
|
|
// --name value a name to say (default: "bob")
|
|
|
|
|
// --help, -h show help
|
|
|
|
|
// --version, -v print the version
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ExampleApp_Run_commandHelp() {
|
|
|
|
|
// set args for examples sake
|
|
|
|
|
os.Args = []string{"greet", "h", "describeit"}
|
|
|
|
|
|
|
|
|
|