()
| 139 | } |
| 140 | |
| 141 | func (cmd HelpCommand) displayCommonCommands() { |
| 142 | cmdInfo := cmd.Actor.CommandInfos(Commands) |
| 143 | |
| 144 | cmd.UI.DisplayText("{{.CommandName}} {{.VersionCommand}} {{.Version}}, {{.CLI}}", |
| 145 | map[string]interface{}{ |
| 146 | "CommandName": cmd.Config.BinaryName(), |
| 147 | "VersionCommand": cmd.UI.TranslateText("version"), |
| 148 | "Version": cmd.Config.BinaryVersion(), |
| 149 | "CLI": cmd.UI.TranslateText("Cloud Foundry command line tool"), |
| 150 | }) |
| 151 | cmd.UI.DisplayText("{{.Usage}} {{.CommandName}} {{.CommandUsage}}", |
| 152 | map[string]interface{}{ |
| 153 | "Usage": cmd.UI.TranslateText("Usage:"), |
| 154 | "CommandName": cmd.Config.BinaryName(), |
| 155 | "CommandUsage": cmd.UI.TranslateText("[global options] command [arguments...] [command options]"), |
| 156 | }) |
| 157 | cmd.UI.DisplayNewline() |
| 158 | |
| 159 | for _, category := range internal.CommonHelpCategoryList { |
| 160 | cmd.UI.DisplayHeader(category.CategoryName) |
| 161 | table := [][]string{} |
| 162 | |
| 163 | for _, row := range category.CommandList { |
| 164 | finalRow := []string{} |
| 165 | |
| 166 | for _, command := range row { |
| 167 | separator := "" |
| 168 | if info, ok := cmdInfo[command]; ok { |
| 169 | if len(info.Alias) > 0 { |
| 170 | separator = "," |
| 171 | } |
| 172 | finalRow = append(finalRow, fmt.Sprint(info.Name, separator, info.Alias)) |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | table = append(table, finalRow) |
| 177 | } |
| 178 | |
| 179 | cmd.UI.DisplayNonWrappingTable(sharedaction.CommonCommandsIndent, table, 4) |
| 180 | cmd.UI.DisplayNewline() |
| 181 | } |
| 182 | |
| 183 | pluginCommands := cmd.getSortedPluginCommands() |
| 184 | |
| 185 | size := int(math.Ceil(float64(len(pluginCommands)) / 3)) |
| 186 | table := make([][]string, size) |
| 187 | for i := 0; i < size; i++ { |
| 188 | table[i] = make([]string, 3) |
| 189 | for j := 0; j < 3; j++ { |
| 190 | index := i + j*size |
| 191 | if index < len(pluginCommands) { |
| 192 | pluginName := pluginCommands[index].Name |
| 193 | if pluginCommands[index].Alias != "" { |
| 194 | pluginName = pluginName + "," + pluginCommands[index].Alias |
| 195 | } |
| 196 | table[i][j] = pluginName |
| 197 | } |
| 198 | } |
no test coverage detected