mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
remove group id of the help command and completion command
This commit is contained in:
parent
a2edfa4d9a
commit
8a2769858c
1 changed files with 24 additions and 0 deletions
24
command.go
24
command.go
|
@ -330,12 +330,25 @@ func (c *Command) SetHelpCommandGroupID(groupID string) {
|
|||
c.helpCommandGroupID = groupID
|
||||
}
|
||||
|
||||
// resetHelpCommandGroupID resets the group id of the help command.
|
||||
func (c *Command) resetHelpCommandGroupID() {
|
||||
if c.helpCommand != nil {
|
||||
c.helpCommand.GroupID = ""
|
||||
}
|
||||
c.helpCommandGroupID = ""
|
||||
}
|
||||
|
||||
// SetCompletionCommandGroupID sets the group id of the completion command.
|
||||
func (c *Command) SetCompletionCommandGroupID(groupID string) {
|
||||
// completionCommandGroupID is used if no completion command is defined by the user
|
||||
c.Root().completionCommandGroupID = groupID
|
||||
}
|
||||
|
||||
// resetCompletionCommandGroupID resets the group id of the completion command.
|
||||
func (c *Command) resetCompletionCommandGroupID() {
|
||||
c.Root().completionCommandGroupID = ""
|
||||
}
|
||||
|
||||
// SetHelpTemplate sets help template to be used. Application can use it to set custom template.
|
||||
func (c *Command) SetHelpTemplate(s string) {
|
||||
c.helpTemplate = s
|
||||
|
@ -1331,6 +1344,17 @@ main:
|
|||
if command.GroupID == groupID {
|
||||
command.GroupID = ""
|
||||
}
|
||||
if command.helpCommandGroupID == groupID {
|
||||
command.resetHelpCommandGroupID()
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, groupID := range groupIDs {
|
||||
if c.helpCommandGroupID == groupID {
|
||||
c.resetHelpCommandGroupID()
|
||||
}
|
||||
if c.Root().completionCommandGroupID == groupID {
|
||||
c.resetCompletionCommandGroupID()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue