MCPcopy
hub / github.com/cloudfoundry/cli / ConvertPluginToCommandInfo

Function ConvertPluginToCommandInfo

command/common/internal/help_display.go:18–53  ·  view source on GitHub ↗
(plugin configv3.PluginCommand)

Source from the content-addressed store, hash-verified

16}
17
18func 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
55func LongestCommandName(cmds map[string]sharedaction.CommandInfo, pluginCmds []configv3.PluginCommand) int {
56 longest := 0

Callers 1

findPluginMethod · 0.92

Calls 1

SortAlphabeticFuncFunction · 0.92

Tested by

no test coverage detected