From 350f7da55d26b8a424028d1bae001f68ed909610 Mon Sep 17 00:00:00 2001 From: Juan Font Date: Sun, 15 Aug 2021 23:20:38 +0200 Subject: [PATCH] Better table in namespaces --- cmd/headscale/cli/namespaces.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/headscale/cli/namespaces.go b/cmd/headscale/cli/namespaces.go index 7d3977f9..e0bc0f20 100644 --- a/cmd/headscale/cli/namespaces.go +++ b/cmd/headscale/cli/namespaces.go @@ -3,8 +3,10 @@ package cli import ( "fmt" "log" + "strconv" "strings" + "github.com/pterm/pterm" "github.com/spf13/cobra" ) @@ -94,9 +96,11 @@ var listNamespacesCmd = &cobra.Command{ fmt.Println(err) return } - fmt.Printf("ID\tName\n") + + d := pterm.TableData{{"ID", "Name", "Created"}} for _, n := range *namespaces { - fmt.Printf("%d\t%s\n", n.ID, n.Name) + d = append(d, []string{strconv.FormatUint(uint64(n.ID), 10), n.Name, n.CreatedAt.Format("2006-01-02 15:04:05")}) } + pterm.DefaultTable.WithHasHeader().WithData(d).Render() }, }