From 6e79899ffbfadc58c061eaadbb83f76570472bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 30 Sep 2024 22:57:06 +0200 Subject: [PATCH] Fix table output --- cmd/list.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/list.go b/cmd/list.go index 4abc8678..251b5aa2 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "os" + "text/tabwriter" "github.com/kovetskiy/lorg" "github.com/kovetskiy/mark/auth" @@ -115,10 +116,12 @@ func ListSpaces(cCtx *cli.Context) error { s, _ := json.MarshalIndent(spaces.Spaces, "", "\t") fmt.Print(string(s)) } else { - fmt.Printf("ID\t\tKey\t\tName\n") + w := tabwriter.NewWriter(os.Stdout, 0, 8, 0, '\t', 0) + fmt.Fprintln(w, "ID\tKey\tName") for _, space := range spaces.Spaces { - fmt.Printf("%s\t\t%s\t\t%d\n", space.Key, space.Name, space.ID) + fmt.Fprintf(w, "%s\t%s\t%d\n", space.Key, space.Name, space.ID) } + w.Flush() } return nil