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