forked from coop-cloud/abra
0
0
Fork 0

fix: recipe versions sorts, aligns & spaces

This commit is contained in:
decentral1se 2023-09-24 11:18:26 +02:00
parent 533edbf172
commit bf648eeb5d
Signed by untrusted user: decentral1se
GPG Key ID: 03789458B3D0C410
2 changed files with 12 additions and 2 deletions

View File

@ -1,12 +1,14 @@
package recipe package recipe
import ( import (
"fmt"
"sort" "sort"
"coopcloud.tech/abra/cli/internal" "coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/autocomplete" "coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/formatter" "coopcloud.tech/abra/pkg/formatter"
recipePkg "coopcloud.tech/abra/pkg/recipe" recipePkg "coopcloud.tech/abra/pkg/recipe"
"github.com/olekukonko/tablewriter"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
@ -17,7 +19,7 @@ func sortServiceByName(versions [][]string) func(i, j int) bool {
if versions[i][1] == "app" { if versions[i][1] == "app" {
return true return true
} }
return false return versions[i][1] < versions[j][1]
} }
} }
@ -53,7 +55,7 @@ var recipeVersionCommand = cli.Command{
} }
for i := len(recipeMeta.Versions) - 1; i >= 0; i-- { for i := len(recipeMeta.Versions) - 1; i >= 0; i-- {
tableCols := []string{"Version", "Service", "Image", "Tag"} tableCols := []string{"version", "service", "image", "tag"}
table := formatter.CreateTable(tableCols) table := formatter.CreateTable(tableCols)
for version, meta := range recipeMeta.Versions[i] { for version, meta := range recipeMeta.Versions[i] {
var versions [][]string var versions [][]string
@ -71,7 +73,9 @@ var recipeVersionCommand = cli.Command{
table.JSONRender() table.JSONRender()
} else { } else {
table.SetAutoMergeCellsByColumnIndex([]int{0}) table.SetAutoMergeCellsByColumnIndex([]int{0})
table.SetAlignment(tablewriter.ALIGN_LEFT)
table.Render() table.Render()
fmt.Println()
} }
} }
} }

View File

@ -191,6 +191,12 @@ func (t *JSONTable) SetAutoMergeCellsByColumnIndex(cols []int) {
t.tbl.SetAutoMergeCellsByColumnIndex(cols) t.tbl.SetAutoMergeCellsByColumnIndex(cols)
} }
// Stuff we should implement but we just proxy for now.
func (t *JSONTable) SetAlignment(align int) {
// FIXME
t.tbl.SetAlignment(align)
}
func (t *JSONTable) SetAutoMergeCells(auto bool) { func (t *JSONTable) SetAutoMergeCells(auto bool) {
// FIXME // FIXME
t.tbl.SetAutoMergeCells(auto) t.tbl.SetAutoMergeCells(auto)