refactor!: vertical render & UI/UX fixes

See coop-cloud/abra#454
This commit is contained in:
2024-12-28 15:30:43 +01:00
committed by decentral1se
parent b6573720ec
commit 97959ef5da
17 changed files with 352 additions and 184 deletions

View File

@ -1,8 +1,6 @@
package recipe
import (
"fmt"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/formatter"
@ -104,7 +102,9 @@ var RecipeLintCommand = &cobra.Command{
}
if len(rows) > 0 {
fmt.Println(table)
if err := formatter.PrintTable(table); err != nil {
log.Fatal(err)
}
for _, warnMsg := range warnMessages {
log.Warn(warnMsg)

View File

@ -79,8 +79,9 @@ var RecipeListCommand = &cobra.Command{
return
}
fmt.Println(table)
log.Infof("total recipes: %v", len(rows))
if err := formatter.PrintTable(table); err != nil {
log.Fatal(err)
}
}
},
}

View File

@ -55,15 +55,32 @@ var RecipeVersionCommand = &cobra.Command{
log.Fatal(err)
}
table.Headers("SERVICE", "NAME", "TAG")
table.Headers("SERVICE", "IMAGE", "TAG", "VERSION")
for version, meta := range recipeMeta.Versions[i] {
var allRows [][]string
var rows [][]string
for service, serviceMeta := range meta {
rows = append(rows, []string{service, serviceMeta.Image, serviceMeta.Tag})
allRows = append(allRows, []string{version, service, serviceMeta.Image, serviceMeta.Tag})
recipeVersion := version
if service != "app" {
recipeVersion = ""
}
rows = append(rows, []string{
service,
serviceMeta.Image,
serviceMeta.Tag,
recipeVersion,
})
allRows = append(allRows, []string{
version,
service,
serviceMeta.Image,
serviceMeta.Tag,
recipeVersion,
})
}
sort.Slice(rows, sortServiceByName(rows))
@ -71,8 +88,9 @@ var RecipeVersionCommand = &cobra.Command{
table.Rows(rows...)
if !internal.MachineReadable {
fmt.Println(table)
log.Infof("VERSION: %s", version)
if err := formatter.PrintTable(table); err != nil {
log.Fatal(err)
}
fmt.Println()
continue
}
@ -100,11 +118,7 @@ var RecipeVersionCommand = &cobra.Command{
func sortServiceByName(versions [][]string) func(i, j int) bool {
return func(i, j int) bool {
// NOTE(d1): corresponds to the `tableCol` definition below
if versions[i][1] == "app" {
return true
}
return versions[i][1] < versions[j][1]
return versions[i][0] < versions[j][0]
}
}