(plugin configv3.PluginCommand)
| 16 | } |
| 17 | |
| 18 | func ConvertPluginToCommandInfo(plugin configv3.PluginCommand) sharedaction.CommandInfo { |
| 19 | commandInfo := sharedaction.CommandInfo{ |
| 20 | Name: plugin.Name, |
| 21 | Description: plugin.HelpText, |
| 22 | Alias: plugin.Alias, |
| 23 | Usage: plugin.UsageDetails.Usage, |
| 24 | Flags: []sharedaction.CommandFlag{}, |
| 25 | } |
| 26 | |
| 27 | flagNames := make([]string, 0, len(plugin.UsageDetails.Options)) |
| 28 | for flag := range plugin.UsageDetails.Options { |
| 29 | flagNames = append(flagNames, flag) |
| 30 | } |
| 31 | sort.Slice(flagNames, sorting.SortAlphabeticFunc(flagNames)) |
| 32 | |
| 33 | for _, flag := range flagNames { |
| 34 | description := plugin.UsageDetails.Options[flag] |
| 35 | strippedFlag := strings.Trim(flag, "-") |
| 36 | switch len(flag) { |
| 37 | case 1: |
| 38 | commandInfo.Flags = append(commandInfo.Flags, |
| 39 | sharedaction.CommandFlag{ |
| 40 | Short: strippedFlag, |
| 41 | Description: description, |
| 42 | }) |
| 43 | default: |
| 44 | commandInfo.Flags = append(commandInfo.Flags, |
| 45 | sharedaction.CommandFlag{ |
| 46 | Long: strippedFlag, |
| 47 | Description: description, |
| 48 | }) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return commandInfo |
| 53 | } |
| 54 | |
| 55 | func LongestCommandName(cmds map[string]sharedaction.CommandInfo, pluginCmds []configv3.PluginCommand) int { |
| 56 | longest := 0 |
no test coverage detected