remove group id of the help command and completion command

This commit is contained in:
Jun Nishimura 2023-07-27 23:51:46 +09:00
parent a2edfa4d9a
commit 8a2769858c
1 changed files with 24 additions and 0 deletions

View File

@ -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()
}
}
}