From 4fc241fb17ec6371aedd3beaf8af22647bb16369 Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Sun, 15 Nov 2015 13:07:28 -0800 Subject: [PATCH 1/3] Update examples to use correct naming convention See https://golang.org/pkg/testing/#hdr-Examples --- app_test.go | 8 ++++---- cli_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app_test.go b/app_test.go index ada5d69..28d8e0f 100644 --- a/app_test.go +++ b/app_test.go @@ -10,7 +10,7 @@ import ( "testing" ) -func ExampleApp() { +func ExampleApp_Run() { // set args for examples sake os.Args = []string{"greet", "--name", "Jeremy"} @@ -30,7 +30,7 @@ func ExampleApp() { // Hello Jeremy } -func ExampleAppSubcommand() { +func ExampleApp_Run_subcommand() { // set args for examples sake os.Args = []string{"say", "hi", "english", "--name", "Jeremy"} app := NewApp() @@ -67,7 +67,7 @@ func ExampleAppSubcommand() { // Hello, Jeremy } -func ExampleAppHelp() { +func ExampleApp_Run_help() { // set args for examples sake os.Args = []string{"greet", "h", "describeit"} @@ -99,7 +99,7 @@ func ExampleAppHelp() { // This is how we describe describeit the function } -func ExampleAppBashComplete() { +func ExampleApp_Run_bashComplete() { // set args for examples sake os.Args = []string{"greet", "--generate-bash-completion"} diff --git a/cli_test.go b/cli_test.go index e54f8e2..4488939 100644 --- a/cli_test.go +++ b/cli_test.go @@ -4,7 +4,7 @@ import ( "os" ) -func Example() { +func Example_App_Run() { app := NewApp() app.Name = "todo" app.Usage = "task list on the command line" @@ -30,7 +30,7 @@ func Example() { app.Run(os.Args) } -func ExampleSubcommand() { +func Example_App_Run_subcommand() { app := NewApp() app.Name = "say" app.Commands = []Command{ From 631930114fcba871b80c458357930649d5783c48 Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Sun, 15 Nov 2015 13:07:49 -0800 Subject: [PATCH 2/3] Also test on Go tip But allow it to fail --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index b08641d..87ba52f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,11 @@ go: - 1.3.3 - 1.4.2 - 1.5.1 +- tip + +matrix: + allow_failures: + - go: tip script: - go vet ./... From 0f218fffa5d7091ccf05ff6568b9f421945e4d19 Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Sun, 15 Nov 2015 13:34:53 -0800 Subject: [PATCH 3/3] Remave cli_test.go Examples are redundant with the ones in app_test.go --- cli_test.go | 98 ----------------------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 cli_test.go diff --git a/cli_test.go b/cli_test.go deleted file mode 100644 index 4488939..0000000 --- a/cli_test.go +++ /dev/null @@ -1,98 +0,0 @@ -package cli - -import ( - "os" -) - -func Example_App_Run() { - app := NewApp() - app.Name = "todo" - app.Usage = "task list on the command line" - app.Commands = []Command{ - { - Name: "add", - Aliases: []string{"a"}, - Usage: "add a task to the list", - Action: func(c *Context) { - println("added task: ", c.Args().First()) - }, - }, - { - Name: "complete", - Aliases: []string{"c"}, - Usage: "complete a task on the list", - Action: func(c *Context) { - println("completed task: ", c.Args().First()) - }, - }, - } - - app.Run(os.Args) -} - -func Example_App_Run_subcommand() { - app := NewApp() - app.Name = "say" - app.Commands = []Command{ - { - Name: "hello", - Aliases: []string{"hi"}, - Usage: "use it to see a description", - Description: "This is how we describe hello the function", - Subcommands: []Command{ - { - Name: "english", - Aliases: []string{"en"}, - Usage: "sends a greeting in english", - Description: "greets someone in english", - Flags: []Flag{ - StringFlag{ - Name: "name", - Value: "Bob", - Usage: "Name of the person to greet", - }, - }, - Action: func(c *Context) { - println("Hello, ", c.String("name")) - }, - }, { - Name: "spanish", - Aliases: []string{"sp"}, - Usage: "sends a greeting in spanish", - Flags: []Flag{ - StringFlag{ - Name: "surname", - Value: "Jones", - Usage: "Surname of the person to greet", - }, - }, - Action: func(c *Context) { - println("Hola, ", c.String("surname")) - }, - }, { - Name: "french", - Aliases: []string{"fr"}, - Usage: "sends a greeting in french", - Flags: []Flag{ - StringFlag{ - Name: "nickname", - Value: "Stevie", - Usage: "Nickname of the person to greet", - }, - }, - Action: func(c *Context) { - println("Bonjour, ", c.String("nickname")) - }, - }, - }, - }, { - Name: "bye", - Usage: "says goodbye", - Action: func(c *Context) { - println("bye") - }, - }, - } - - app.Run(os.Args) -}