From bf648eeb5d256959b6b3a6a16024dea8cf27350e Mon Sep 17 00:00:00 2001 From: decentral1se Date: Sun, 24 Sep 2023 11:18:26 +0200 Subject: [PATCH] fix: recipe versions sorts, aligns & spaces --- cli/recipe/version.go | 8 ++++++-- pkg/jsontable/jsontable.go | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cli/recipe/version.go b/cli/recipe/version.go index c29859e0..db276fe5 100644 --- a/cli/recipe/version.go +++ b/cli/recipe/version.go @@ -1,12 +1,14 @@ package recipe import ( + "fmt" "sort" "coopcloud.tech/abra/cli/internal" "coopcloud.tech/abra/pkg/autocomplete" "coopcloud.tech/abra/pkg/formatter" recipePkg "coopcloud.tech/abra/pkg/recipe" + "github.com/olekukonko/tablewriter" "github.com/sirupsen/logrus" "github.com/urfave/cli" ) @@ -17,7 +19,7 @@ func sortServiceByName(versions [][]string) func(i, j int) bool { if versions[i][1] == "app" { 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-- { - tableCols := []string{"Version", "Service", "Image", "Tag"} + tableCols := []string{"version", "service", "image", "tag"} table := formatter.CreateTable(tableCols) for version, meta := range recipeMeta.Versions[i] { var versions [][]string @@ -71,7 +73,9 @@ var recipeVersionCommand = cli.Command{ table.JSONRender() } else { table.SetAutoMergeCellsByColumnIndex([]int{0}) + table.SetAlignment(tablewriter.ALIGN_LEFT) table.Render() + fmt.Println() } } } diff --git a/pkg/jsontable/jsontable.go b/pkg/jsontable/jsontable.go index e869350a..ef49137c 100644 --- a/pkg/jsontable/jsontable.go +++ b/pkg/jsontable/jsontable.go @@ -191,6 +191,12 @@ func (t *JSONTable) SetAutoMergeCellsByColumnIndex(cols []int) { 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) { // FIXME t.tbl.SetAutoMergeCells(auto)