Skip to content

Commit

Permalink
feat: fctl displaying
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ragot committed Dec 22, 2023
1 parent 57856a1 commit 821df06
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions components/fctl/cmd/auth/clients/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package clients

import (
"fmt"
"strings"

fctl "github.com/formancehq/fctl/pkg"
"github.com/formancehq/formance-sdk-go/pkg/models/shared"
Expand All @@ -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 {
Expand Down Expand Up @@ -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),
}
})
Expand All @@ -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()).
Expand Down

0 comments on commit 821df06

Please sign in to comment.