(definition parser.Definition)
| 465 | } |
| 466 | |
| 467 | func (b CommandBuilder) createServiceCommand(definition parser.Definition) *CommandDefinition { |
| 468 | categories := map[string]*CommandDefinition{} |
| 469 | commands := []*CommandDefinition{} |
| 470 | for _, operation := range definition.Operations { |
| 471 | if operation.Category == nil { |
| 472 | command := b.createOperationCommand(operation) |
| 473 | commands = append(commands, command) |
| 474 | continue |
| 475 | } |
| 476 | isNewCategory, command := b.createServiceCommandCategory(operation, categories) |
| 477 | if isNewCategory { |
| 478 | commands = append(commands, command) |
| 479 | } |
| 480 | } |
| 481 | b.sort(commands) |
| 482 | for _, command := range commands { |
| 483 | b.sort(command.Subcommands) |
| 484 | } |
| 485 | |
| 486 | flags := NewFlagBuilder(). |
| 487 | AddHelpFlag(). |
| 488 | AddServiceVersionFlag(true). |
| 489 | Build() |
| 490 | |
| 491 | return NewCommand(definition.Name, definition.Summary, definition.Description). |
| 492 | WithFlags(flags). |
| 493 | WithSubcommands(commands) |
| 494 | } |
| 495 | |
| 496 | func (b CommandBuilder) createAutoCompleteEnableCommand() *CommandDefinition { |
| 497 | const shellFlagName = "shell" |
no test coverage detected