From 821df06bad90bcf3e1e1b3ae73e972746de87113 Mon Sep 17 00:00:00 2001 From: David Ragot Date: Fri, 22 Dec 2023 20:25:47 +0100 Subject: [PATCH] feat: fctl displaying --- components/fctl/cmd/auth/clients/list.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/components/fctl/cmd/auth/clients/list.go b/components/fctl/cmd/auth/clients/list.go index 63a11cd740..8a7059be52 100644 --- a/components/fctl/cmd/auth/clients/list.go +++ b/components/fctl/cmd/auth/clients/list.go @@ -2,7 +2,6 @@ package clients import ( "fmt" - "strings" fctl "github.com/formancehq/fctl/pkg" "github.com/formancehq/formance-sdk-go/pkg/models/shared" @@ -11,11 +10,11 @@ import ( ) type Client struct { - ID string `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - IsPublic string `json:"isPublic"` - Scopes string `json:"scopes"` + ID string `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + IsPublic string `json:"isPublic"` + Scopes []string `json:"scopes"` } type ListStore struct { @@ -90,7 +89,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable } return "" }(), - Scopes: strings.Join(o.Scopes, ", "), + Scopes: o.Scopes, IsPublic: fctl.BoolPointerToString(o.Public), } }) @@ -105,11 +104,16 @@ func (c *ListController) Render(cmd *cobra.Command, args []string) error { o.Name, o.Description, o.IsPublic, - o.Scopes, + func() string { + if len(o.Scopes) == 0 { + return "No permissions" + } + return fmt.Sprintf("%d", len(o.Scopes)) + }(), } }) - tableData = fctl.Prepend(tableData, []string{"ID", "Name", "Description", "Public", "Scopes"}) + tableData = fctl.Prepend(tableData, []string{"ID", "Name", "Description", "Public", "Scopes count"}) return pterm.DefaultTable. WithHasHeader(). WithWriter(cmd.OutOrStdout()).