|
|
|
@ -377,3 +377,48 @@ func TestCommand_Run_CustomShellCompleteAcceptsMalformedFlags(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCommand_NoVersionFlagOnCommands(t *testing.T) {
|
|
|
|
|
app := &App{
|
|
|
|
|
Version: "some version",
|
|
|
|
|
Commands: []*Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "bar",
|
|
|
|
|
Usage: "this is for testing",
|
|
|
|
|
Subcommands: []*Command{{}}, // some subcommand
|
|
|
|
|
HideHelp: true,
|
|
|
|
|
Action: func(c *Context) error {
|
|
|
|
|
if len(c.App.VisibleFlags()) != 0 {
|
|
|
|
|
t.Fatal("unexpected flag on command")
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|