refactor: use method to sort recipe apps listing

This commit is contained in:
decentral1se 2021-07-26 15:43:35 +02:00
parent 13028db287
commit 1f62ace524
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 10 additions and 10 deletions

View File

@ -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}