MCPcopy Create free account
hub / github.com/apache/openwhisk-cli / printList

Function printList

commands/util.go:192–232  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)
192func 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
234func quickSort(toSort Sortables, left int, right int) {
235 low := left

Callers 7

activation.goFile · 0.85
api.goFile · 0.85
rule.goFile · 0.85
package.goFile · 0.85
trigger.goFile · 0.85
action.goFile · 0.85
namespace.goFile · 0.85

Calls 4

quickSortFunction · 0.85
printCommandsListFunction · 0.85
toPrintableFunction · 0.85
makeDefaultHeaderFunction · 0.85

Tested by

no test coverage detected