Capture immutable command declarations
This commit is contained in:
@@ -127,10 +127,7 @@ func performanceFlatCommands(tb testing.TB, count int, prefix string) []commandk
|
||||
return commandkit.Usage(performanceUsageCause)
|
||||
}
|
||||
}
|
||||
command, err := commandkit.NewCommand(commandkit.CommandSpec[struct{}]{Name: name, Summary: "Benchmark command.", Flags: flags, Run: run})
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
command := commandkit.NewCommand(commandkit.CommandSpec[struct{}]{Name: name, Summary: "Benchmark command.", Flags: flags, Run: run})
|
||||
commands = append(commands, command)
|
||||
}
|
||||
return commands
|
||||
@@ -142,20 +139,11 @@ func performanceNestedCommand(tb testing.TB) (commandkit.Command, []string) {
|
||||
for index := range path {
|
||||
path[index] = fmt.Sprintf("level%02d", index)
|
||||
}
|
||||
leaf, err := commandkit.NewCommand(commandkit.CommandSpec[struct{}]{Name: path[len(path)-1], Summary: "Nested benchmark command.", Run: func(commandkit.Invocation, struct{}) commandkit.Outcome { return commandkit.Success() }})
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
leaf := commandkit.NewCommand(commandkit.CommandSpec[struct{}]{Name: path[len(path)-1], Summary: "Nested benchmark command.", Run: func(commandkit.Invocation, struct{}) commandkit.Outcome { return commandkit.Success() }})
|
||||
current := leaf
|
||||
for index := len(path) - 2; index >= 0; index-- {
|
||||
sibling, err := commandkit.NewCommand(commandkit.CommandSpec[struct{}]{Name: fmt.Sprintf("sibling%02d", index), Summary: "Sibling command.", Run: func(commandkit.Invocation, struct{}) commandkit.Outcome { return commandkit.Success() }})
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
current, err = commandkit.Group(path[index], "Nested benchmark group.", current, sibling)
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
sibling := commandkit.NewCommand(commandkit.CommandSpec[struct{}]{Name: fmt.Sprintf("sibling%02d", index), Summary: "Sibling command.", Run: func(commandkit.Invocation, struct{}) commandkit.Outcome { return commandkit.Success() }})
|
||||
current = commandkit.Group(path[index], "Nested benchmark group.", current, sibling)
|
||||
}
|
||||
return current, path
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user