added test for successfully used -v flag on command with subcommands
This commit is contained in:
parent
1f3e0b5233
commit
ef2d047c45
@ -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
|
||||
},
|
||||
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user