forked from toolshed/abra
		
	refactor: use method to sort recipe apps listing
This commit is contained in:
		| @ -54,6 +54,15 @@ type App struct { | ||||
|  | ||||
| type Apps map[string]App | ||||
|  | ||||
| func (a Apps) SortByName() []string { | ||||
| 	var names []string | ||||
| 	for name := range a { | ||||
| 		names = append(names, name) | ||||
| 	} | ||||
| 	sort.Strings(names) | ||||
| 	return names | ||||
| } | ||||
|  | ||||
| var httpClient = &http.Client{Timeout: 5 * time.Second} | ||||
|  | ||||
| var AppsUrl = "https://apps.coopcloud.tech" | ||||
| @ -147,15 +156,6 @@ func ReadAppsWeb(target interface{}) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func SortByAppName(apps Apps) []string { | ||||
| 	var names []string | ||||
| 	for name := range apps { | ||||
| 		names = append(names, name) | ||||
| 	} | ||||
| 	sort.Strings(names) | ||||
| 	return names | ||||
| } | ||||
|  | ||||
| var recipeListCommand = &cli.Command{ | ||||
| 	Name:    "list", | ||||
| 	Aliases: []string{"ls"}, | ||||
| @ -166,7 +166,7 @@ var recipeListCommand = &cli.Command{ | ||||
| 		} | ||||
| 		tableCol := []string{"Name", "Category", "Status"} | ||||
| 		table := createTable(tableCol) | ||||
| 		for _, name := range SortByAppName(apps) { | ||||
| 		for _, name := range apps.SortByName() { | ||||
| 			app := apps[name] | ||||
| 			status := fmt.Sprintf("%v", app.Features.Status) | ||||
| 			tableRow := []string{app.Name, app.Category, status} | ||||
|  | ||||
		Reference in New Issue
	
	Block a user