Better table in namespaces

This commit is contained in:
Juan Font 2021-08-15 23:20:38 +02:00
parent 36f5f78f46
commit 350f7da55d

View file

@ -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()
},
}