Skip to content

Commit

Permalink
added test for successfully used -v flag on command with subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
Irioth committed Jun 18, 2020
1 parent 1f3e0b5 commit ef2d047
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion command_test.go
Expand Up @@ -389,7 +389,7 @@ func TestCommand_NoVersionFlagOnCommands(t *testing.T) {
HideHelp: true,
Action: func(c *Context) error {
if len(c.App.VisibleFlags()) != 0 {
t.Fatalf("unexpected flag on command")
t.Fatal("unexpected flag on command")
}
return nil
},
Expand All @@ -400,3 +400,25 @@ func TestCommand_NoVersionFlagOnCommands(t *testing.T) {
err := app.Run([]string{"foo", "bar"})
expect(t, err, nil)
}

func TestCommand_CanAddVFlagOnCommands(t *testing.T) {
app := &App{
Version: "some version",
Writer: ioutil.Discard,
Commands: []*Command{
{
Name: "bar",
Usage: "this is for testing",
Subcommands: []*Command{{}}, // some subcommand
Flags: []Flag{
&BoolFlag{
Name: "v",
},
},
},
},
}

err := app.Run([]string{"foo", "bar"})
expect(t, err, nil)
}

0 comments on commit ef2d047

Please sign in to comment.