From 85c3eadea41bbfcbb73ad334f5a54811ce500a93 Mon Sep 17 00:00:00 2001 From: Summer Mousa Date: Sat, 12 Apr 2014 17:13:47 -0500 Subject: [PATCH] Adding sample test --- app_test.go | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/app_test.go b/app_test.go index 4e94f9e..49c525c 100644 --- a/app_test.go +++ b/app_test.go @@ -35,9 +35,9 @@ func ExampleAppHelp() { } app.Commands = []cli.Command{ { - Name: "describeit", - ShortName: "d", - Usage: "use it to see a description", + 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") @@ -58,6 +58,41 @@ func ExampleAppHelp() { // OPTIONS: } +func ExampleAppBashComplete() { + // set args for examples sake + os.Args = []string{"greet", "--generate-bash-completion"} + + app := cli.NewApp() + app.Name = "greet" + app.EnableBashCompletion = true + 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") + }, + }, { + Name: "next", + Usage: "next example", + Description: "more stuff to see when generating bash completion", + Action: func(c *cli.Context) { + fmt.Printf("the next example") + }, + }, + } + + app.Run(os.Args) + // Output: + // describeit + // d + // next + // help + // h +} + func TestApp_Run(t *testing.T) { s := ""