Skip to content

Commit

Permalink
remove group id of the help command and completion command
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Jul 27, 2023
1 parent a2edfa4 commit 8a27698
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}
}
Expand Down

0 comments on commit 8a27698

Please sign in to comment.