Better testing support. Easy to reset to blank slate in tests.
This commit is contained in:
5
cobra.go
5
cobra.go
@ -150,6 +150,11 @@ func (c *Command) execute(args []string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// Used for testing
|
||||
func (c *Command) ResetCommands() {
|
||||
c.commands = nil
|
||||
}
|
||||
|
||||
// Add one or many commands as children of this
|
||||
func (c *Command) AddCommand(cmds ...*Command) {
|
||||
for i, x := range cmds {
|
||||
|
Reference in New Issue
Block a user