Skip to content

Commit

Permalink
Fix table output
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Rüger committed Sep 30, 2024
1 parent 5f2e458 commit 6e79899
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"os"
"text/tabwriter"

"github.com/kovetskiy/lorg"
"github.com/kovetskiy/mark/auth"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6e79899

Please sign in to comment.