Merge branch 'develop' of https://github.com/txgruppi/cli into txgruppi-develop

This commit is contained in:
Dan Buch
2016-04-25 18:10:10 -04:00
11 changed files with 346 additions and 197 deletions

View File

@@ -34,12 +34,12 @@ func TestCommandFlagParsing(t *testing.T) {
Aliases: []string{"tc"},
Usage: "this is for testing",
Description: "testing",
Action: func(_ *Context) {},
Action: func(_ *Context) int { return 0 },
}
command.SkipFlagParsing = c.skipFlagParsing
err := command.Run(context)
_, err := command.Run(context)
expect(t, err, c.expectedErr)
expect(t, []string(context.Args()), c.testArgs)
@@ -50,13 +50,17 @@ func TestCommand_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {
app := NewApp()
app.Commands = []Command{
Command{
Name: "bar",
Before: func(c *Context) error { return fmt.Errorf("before error") },
After: func(c *Context) error { return fmt.Errorf("after error") },
Name: "bar",
Before: func(c *Context) (int, error) {
return 1, fmt.Errorf("before error")
},
After: func(c *Context) (int, error) {
return 1, fmt.Errorf("after error")
},
},
}
err := app.Run([]string{"foo", "bar"})
_, err := app.Run([]string{"foo", "bar"})
if err == nil {
t.Fatalf("expected to receive error from Run, got none")
}
@@ -73,7 +77,7 @@ func TestCommand_OnUsageError_WithWrongFlagValue(t *testing.T) {
app := NewApp()
app.Commands = []Command{
Command{
Name: "bar",
Name: "bar",
Flags: []Flag{
IntFlag{Name: "flag"},
},
@@ -86,7 +90,7 @@ func TestCommand_OnUsageError_WithWrongFlagValue(t *testing.T) {
},
}
err := app.Run([]string{"foo", "bar", "--flag=wrong"})
_, err := app.Run([]string{"foo", "bar", "--flag=wrong"})
if err == nil {
t.Fatalf("expected to receive error from Run, got none")
}