Skip to content

Commit

Permalink
group: only add if not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Jan 13, 2023
1 parent 7e73b34 commit 5ea671e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ func (c *Command) ToCobra() *cobra.Command {

groups := make(map[string]bool)
for _, subcmd := range c.Commands {
if _, exists := groups[subcmd.Group]; !exists {
cmd.AddGroup(&cobra.Group{ID: subcmd.Group})
groups[subcmd.Group] = true
if subcmd.Group != "" {
if _, exists := groups[subcmd.Group]; !exists {
cmd.AddGroup(&cobra.Group{ID: subcmd.Group})
groups[subcmd.Group] = true
}
}
cmd.AddCommand(subcmd.ToCobra())
}
Expand Down

0 comments on commit 5ea671e

Please sign in to comment.