Prints the parameters/list for wsk xxxx list Identifies type and then copies array into an array of interfaces(Sortable) to be sorted and printed Param: Takes in an interface which contains an array of a command(Ex: []Action)
(collection interface{}, sortByName bool)
| 190 | // Identifies type and then copies array into an array of interfaces(Sortable) to be sorted and printed |
| 191 | // Param: Takes in an interface which contains an array of a command(Ex: []Action) |
| 192 | func printList(collection interface{}, sortByName bool) { |
| 193 | var commandToSort []whisk.Sortable |
| 194 | switch collection := collection.(type) { |
| 195 | case []whisk.Action: |
| 196 | for i := range collection { |
| 197 | commandToSort = append(commandToSort, collection[i]) |
| 198 | } |
| 199 | case []whisk.Trigger: |
| 200 | for i := range collection { |
| 201 | commandToSort = append(commandToSort, collection[i]) |
| 202 | } |
| 203 | case []whisk.Package: |
| 204 | for i := range collection { |
| 205 | commandToSort = append(commandToSort, collection[i]) |
| 206 | } |
| 207 | case []whisk.Rule: |
| 208 | for i := range collection { |
| 209 | commandToSort = append(commandToSort, collection[i]) |
| 210 | } |
| 211 | case []whisk.Namespace: |
| 212 | for i := range collection { |
| 213 | commandToSort = append(commandToSort, collection[i]) |
| 214 | } |
| 215 | case []whisk.ActivationFilteredRow: |
| 216 | for i := range collection { |
| 217 | commandToSort = append(commandToSort, collection[i]) |
| 218 | } |
| 219 | case []whisk.ApiFilteredList: |
| 220 | for i := range collection { |
| 221 | commandToSort = append(commandToSort, collection[i]) |
| 222 | } |
| 223 | case []whisk.ApiFilteredRow: |
| 224 | for i := range collection { |
| 225 | commandToSort = append(commandToSort, collection[i]) |
| 226 | } |
| 227 | } |
| 228 | if sortByName && len(commandToSort) > 0 { |
| 229 | quickSort(commandToSort, 0, len(commandToSort)-1) |
| 230 | } |
| 231 | printCommandsList(toPrintable(commandToSort), makeDefaultHeader(collection)) |
| 232 | } |
| 233 | |
| 234 | func quickSort(toSort Sortables, left int, right int) { |
| 235 | low := left |
no test coverage detected