Skip to content

Commit 094a9bc

Browse files
authored
Merge pull request #1857 from 1ambd4/v2-refactor-cli-app-setup
Cleanup: Remove unnecessary intermediate variables
2 parents 7656c5f + c3abd2a commit 094a9bc

File tree

2 files changed

+0
-7
lines changed

2 files changed

+0
-7
lines changed

app.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,6 @@ func (a *App) Setup() {
229229
a.separator.disabled = true
230230
}
231231

232-
var newCommands []*Command
233-
234232
for _, c := range a.Commands {
235233
cname := c.Name
236234
if c.HelpName != "" {
@@ -239,9 +237,7 @@ func (a *App) Setup() {
239237
c.separator = a.separator
240238
c.HelpName = fmt.Sprintf("%s %s", a.HelpName, cname)
241239
c.flagCategories = newFlagCategoriesFromFlags(c.Flags)
242-
newCommands = append(newCommands, c)
243240
}
244-
a.Commands = newCommands
245241

246242
if a.Command(helpCommand.Name) == nil && !a.HideHelp {
247243
if !a.HideHelpCommand {

command.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,12 @@ func (c *Command) setup(ctx *Context) {
132132
}
133133
sort.Sort(c.categories.(*commandCategories))
134134

135-
var newCmds []*Command
136135
for _, scmd := range c.Subcommands {
137136
if scmd.HelpName == "" {
138137
scmd.HelpName = fmt.Sprintf("%s %s", c.HelpName, scmd.Name)
139138
}
140139
scmd.separator = c.separator
141-
newCmds = append(newCmds, scmd)
142140
}
143-
c.Subcommands = newCmds
144141

145142
if c.BashComplete == nil {
146143
c.BashComplete = DefaultCompleteWithFlags(c)

0 commit comments

Comments
 (0)