Install command batches through one path
This commit is contained in:
@@ -5,13 +5,17 @@ import "fmt"
|
||||
// Register adds a batch of root commands to the application. The batch is
|
||||
// validated before the registry is changed.
|
||||
func (a *App) Register(commands ...Command) error {
|
||||
return a.installBatch(commands...)
|
||||
}
|
||||
|
||||
func (a *App) installBatch(commands ...Command) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("cannot register commands on a nil app")
|
||||
}
|
||||
|
||||
pending := make(map[string]*commandNode, len(commands))
|
||||
for _, command := range commands {
|
||||
if err := validateCommandDeclaration(command); err != nil {
|
||||
if err := validateCommandPlacement(command); err != nil {
|
||||
return err
|
||||
}
|
||||
if command.record.absent {
|
||||
|
||||
Reference in New Issue
Block a user