From a70d0bb136e8db8e0e211af7b95be86bdae18e0b Mon Sep 17 00:00:00 2001 From: Mr Rogers Date: Wed, 19 Feb 2014 16:32:01 -0500 Subject: [PATCH 1/3] add tests for description output --- app_test.go | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/app_test.go b/app_test.go index f329b91..99eb620 100644 --- a/app_test.go +++ b/app_test.go @@ -24,6 +24,40 @@ func ExampleApp() { // 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) { s := "" @@ -53,7 +87,7 @@ var commandAppTests = []struct { func TestApp_Command(t *testing.T) { 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"} app.Commands = []cli.Command{ fooCommand, @@ -121,6 +155,7 @@ func TestApp_ParseSliceFlags(t *testing.T) { firstArg = c.Args().First() }, } + 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"}) From 1ccba5fbb59ba1b0422e3c3b3cb112c392ea483f Mon Sep 17 00:00:00 2001 From: Mr Rogers Date: Wed, 19 Feb 2014 16:37:20 -0500 Subject: [PATCH 2/3] fix whitespace --- app_test.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app_test.go b/app_test.go index 99eb620..b5c20f5 100644 --- a/app_test.go +++ b/app_test.go @@ -34,28 +34,28 @@ func ExampleAppHelp() { 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") - }, + fmt.Printf("i like to describe things") + }, }, } app.Run(os.Args) // Output: - // NAME: - // describeit - use it to see a description + // NAME: + // describeit - use it to see a description + // + // USAGE: + // command describeit [command options] [arguments...] // - // USAGE: - // command describeit [command options] [arguments...] + // DESCRIPTION: + // This is how we describe describeit the function // - // DESCRIPTION: - // This is how we describe describeit the function - // - // OPTIONS: + // OPTIONS: } func TestApp_Run(t *testing.T) { From b4d98765bd19f24e37e65833d08f27e0de6970bb Mon Sep 17 00:00:00 2001 From: Mr Rogers Date: Wed, 19 Feb 2014 16:38:51 -0500 Subject: [PATCH 3/3] rollback inconsequential changes --- app_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app_test.go b/app_test.go index b5c20f5..4e94f9e 100644 --- a/app_test.go +++ b/app_test.go @@ -87,7 +87,7 @@ var commandAppTests = []struct { func TestApp_Command(t *testing.T) { app := cli.NewApp() - fooCommand := cli.Command{Name: "foobar", ShortName: "f", Description: "Foobar is nuts",} + fooCommand := cli.Command{Name: "foobar", ShortName: "f"} batCommand := cli.Command{Name: "batbaz", ShortName: "b"} app.Commands = []cli.Command{ fooCommand, @@ -155,7 +155,6 @@ func TestApp_ParseSliceFlags(t *testing.T) { firstArg = c.Args().First() }, } - 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"})