(command *CommandDefinition)
| 129 | } |
| 130 | |
| 131 | func (c Cli) convertCommand(command *CommandDefinition) *cli.Command { |
| 132 | result := cli.Command{ |
| 133 | Name: command.Name, |
| 134 | Usage: command.Summary, |
| 135 | Description: command.Description, |
| 136 | Flags: c.convertFlags(command.Flags...), |
| 137 | Commands: c.convertCommands(command.Subcommands...), |
| 138 | CustomHelpTemplate: command.HelpTemplate, |
| 139 | Hidden: command.Hidden, |
| 140 | HideHelp: true, |
| 141 | DisableSliceFlagSeparator: true, |
| 142 | CommandNotFound: func(ctx context.Context, cmd *cli.Command, commandName string) { |
| 143 | if cmd != nil { |
| 144 | root := cmd.Root() |
| 145 | root.CommandNotFound(ctx, cmd, commandName) |
| 146 | } |
| 147 | }, |
| 148 | OnUsageError: func(ctx context.Context, cmd *cli.Command, err error, isSubcommand bool) error { |
| 149 | return fmt.Errorf("Incorrect usage: %w", err) |
| 150 | }, |
| 151 | } |
| 152 | if command.Action != nil { |
| 153 | result.Action = func(ctx context.Context, cmd *cli.Command) error { |
| 154 | return command.Action(&CommandExecContext{cmd, ctx}) |
| 155 | } |
| 156 | } |
| 157 | return &result |
| 158 | } |
| 159 | |
| 160 | func (c Cli) convertCommands(commands ...*CommandDefinition) []*cli.Command { |
| 161 | result := []*cli.Command{} |
no test coverage detected