add tests for description output
This commit is contained in:
parent
161c7e7496
commit
a70d0bb136
37
app_test.go
37
app_test.go
@ -24,6 +24,40 @@ func ExampleApp() {
|
|||||||
// Hello Jeremy
|
// Hello Jeremy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ExampleAppHelp() {
|
||||||
|
// set args for examples sake
|
||||||
|
os.Args = []string{"greet", "h", "describeit"}
|
||||||
|
|
||||||
|
app := cli.NewApp()
|
||||||
|
app.Name = "greet"
|
||||||
|
app.Flags = []cli.Flag{
|
||||||
|
cli.StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
|
||||||
|
}
|
||||||
|
app.Commands = []cli.Command{
|
||||||
|
{
|
||||||
|
Name: "describeit",
|
||||||
|
ShortName: "d",
|
||||||
|
Usage: "use it to see a description",
|
||||||
|
Description: "This is how we describe describeit the function",
|
||||||
|
Action: func(c *cli.Context) {
|
||||||
|
fmt.Printf("i like to describe things")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
app.Run(os.Args)
|
||||||
|
// Output:
|
||||||
|
// NAME:
|
||||||
|
// describeit - use it to see a description
|
||||||
|
//
|
||||||
|
// USAGE:
|
||||||
|
// command describeit [command options] [arguments...]
|
||||||
|
//
|
||||||
|
// DESCRIPTION:
|
||||||
|
// This is how we describe describeit the function
|
||||||
|
//
|
||||||
|
// OPTIONS:
|
||||||
|
}
|
||||||
|
|
||||||
func TestApp_Run(t *testing.T) {
|
func TestApp_Run(t *testing.T) {
|
||||||
s := ""
|
s := ""
|
||||||
|
|
||||||
@ -53,7 +87,7 @@ var commandAppTests = []struct {
|
|||||||
|
|
||||||
func TestApp_Command(t *testing.T) {
|
func TestApp_Command(t *testing.T) {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
fooCommand := cli.Command{Name: "foobar", ShortName: "f"}
|
fooCommand := cli.Command{Name: "foobar", ShortName: "f", Description: "Foobar is nuts",}
|
||||||
batCommand := cli.Command{Name: "batbaz", ShortName: "b"}
|
batCommand := cli.Command{Name: "batbaz", ShortName: "b"}
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []cli.Command{
|
||||||
fooCommand,
|
fooCommand,
|
||||||
@ -121,6 +155,7 @@ func TestApp_ParseSliceFlags(t *testing.T) {
|
|||||||
firstArg = c.Args().First()
|
firstArg = c.Args().First()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Commands = []cli.Command{command}
|
app.Commands = []cli.Command{command}
|
||||||
|
|
||||||
app.Run([]string{"", "cmd", "my-arg", "-p", "22", "-p", "80", "-ip", "8.8.8.8", "-ip", "8.8.4.4"})
|
app.Run([]string{"", "cmd", "my-arg", "-p", "22", "-p", "80", "-ip", "8.8.8.8", "-ip", "8.8.4.4"})
|
||||||
|
Loading…
Reference in New Issue
Block a user