Skip to content

Commit

Permalink
Merge pull request #1857 from 1ambd4/v2-refactor-cli-app-setup
Browse files Browse the repository at this point in the history
Cleanup: Remove unnecessary intermediate variables
  • Loading branch information
dearchap committed Jan 10, 2024
2 parents 7656c5f + c3abd2a commit 094a9bc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 7 deletions.
4 changes: 0 additions & 4 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ func (a *App) Setup() {
a.separator.disabled = true
}

var newCommands []*Command

for _, c := range a.Commands {
cname := c.Name
if c.HelpName != "" {
Expand All @@ -239,9 +237,7 @@ func (a *App) Setup() {
c.separator = a.separator
c.HelpName = fmt.Sprintf("%s %s", a.HelpName, cname)
c.flagCategories = newFlagCategoriesFromFlags(c.Flags)
newCommands = append(newCommands, c)
}
a.Commands = newCommands

if a.Command(helpCommand.Name) == nil && !a.HideHelp {
if !a.HideHelpCommand {
Expand Down
3 changes: 0 additions & 3 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,12 @@ func (c *Command) setup(ctx *Context) {
}
sort.Sort(c.categories.(*commandCategories))

var newCmds []*Command
for _, scmd := range c.Subcommands {
if scmd.HelpName == "" {
scmd.HelpName = fmt.Sprintf("%s %s", c.HelpName, scmd.Name)
}
scmd.separator = c.separator
newCmds = append(newCmds, scmd)
}
c.Subcommands = newCmds

if c.BashComplete == nil {
c.BashComplete = DefaultCompleteWithFlags(c)
Expand Down

0 comments on commit 094a9bc

Please sign in to comment.