Merge pull request #75 from Winslett/command-not-found

Customizable command not found function
This commit is contained in:
Jeremy Saenz
2014-04-22 20:33:49 -07:00
3 changed files with 30 additions and 1 deletions

View File

@@ -346,3 +346,26 @@ func TestAppHelpPrinter(t *testing.T) {
t.Errorf("Help printer expected to be called, but was not")
}
}
func TestAppCommandNotFound(t *testing.T) {
beforeRun, subcommandRun := false, false
app := cli.NewApp()
app.CommandNotFound = func(c *cli.Context, command string) {
beforeRun = true
}
app.Commands = []cli.Command{
cli.Command{
Name: "bar",
Action: func(c *cli.Context) {
subcommandRun = true
},
},
}
app.Run([]string{"command", "foo"})
expect(t, beforeRun, true)
expect(t, subcommandRun, false)
}