Skip to content

Commit

Permalink
Merge pull request #110 from auth0/CLI-36
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket authored Feb 26, 2021
2 parents d0d5dd2 + ebb5ed4 commit fac25a0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
4 changes: 2 additions & 2 deletions internal/cli/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func TestClientsListCmd(t *testing.T) {
}

expectTable(t, stdout.String(),
[]string{"NAME", "TYPE", "CLIENT ID", "CALLBACKS"},
[]string{"NAME", "TYPE", "CLIENT ID"},
[][]string{
{"some-name", "generic", "some-id", "http://localhost"},
{"some-name", "generic", "some-id"},
},
)
}
50 changes: 40 additions & 10 deletions internal/display/clients.go → internal/display/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
quickstartsGeneric = "https://auth0.com/docs/quickstarts"
)

type clientView struct {
type applicationView struct {
Name string
Type string
ClientID string
Expand All @@ -26,15 +26,14 @@ type clientView struct {
revealSecret bool
}

func (v *clientView) AsTableHeader() []string {
func (v *applicationView) AsTableHeader() []string {
if v.revealSecret {
return []string{"Name", "Type", "ClientID", "Client Secret", "Callbacks"}
}
return []string{"Name", "Type", "Client ID", "Callbacks"}

}

func (v *clientView) AsTableRow() []string {
func (v *applicationView) AsTableRow() []string {
if v.revealSecret {
return []string{
v.Name,
Expand All @@ -53,19 +52,52 @@ func (v *clientView) AsTableRow() []string {

}

// applicationListView is a slimmed down view of a client for displaying
// larger numbers of applications
type applicationListView struct {
Name string
Type string
ClientID string
ClientSecret string
revealSecret bool
}

func (v *applicationListView) AsTableHeader() []string {
if v.revealSecret {
return []string{"Name", "Type", "ClientID", "Client Secret"}
}
return []string{"Name", "Type", "Client ID"}

}

func (v *applicationListView) AsTableRow() []string {
if v.revealSecret {
return []string{
v.Name,
v.Type,
ansi.Faint(v.ClientID),
ansi.Italic(v.ClientSecret),
}
}
return []string{
v.Name,
v.Type,
ansi.Faint(v.ClientID),
}
}

func (r *Renderer) ApplicationList(clients []*management.Client) {
r.Heading(ansi.Bold(r.Tenant), "applications\n")
var res []View
for _, c := range clients {
if auth0.StringValue(c.Name) == deprecatedAppName {
continue
}
res = append(res, &clientView{
res = append(res, &applicationListView{
Name: auth0.StringValue(c.Name),
Type: appTypeFor(c.AppType),
ClientID: auth0.StringValue(c.ClientID),
ClientSecret: auth0.StringValue(c.ClientSecret),
Callbacks: callbacksFor(c.Callbacks),
})
}

Expand All @@ -75,9 +107,7 @@ func (r *Renderer) ApplicationList(clients []*management.Client) {
func (r *Renderer) ApplicationCreate(client *management.Client, revealSecrets bool) {
r.Heading(ansi.Bold(r.Tenant), "application created\n")

// note(jfatta): list and create uses the same view for now,
// eventually we might want to show different columns for each command:
v := &clientView{
v := &applicationView{
revealSecret: revealSecrets,
Name: auth0.StringValue(client.Name),
Type: appTypeFor(client.AppType),
Expand All @@ -94,7 +124,7 @@ func (r *Renderer) ApplicationCreate(client *management.Client, revealSecrets bo
func (r *Renderer) ApplicationUpdate(client *management.Client, revealSecrets bool) {
r.Heading(ansi.Bold(r.Tenant), "application updated\n")

v := &clientView{
v := &applicationView{
revealSecret: revealSecrets,
Name: auth0.StringValue(client.Name),
Type: appTypeFor(client.AppType),
Expand Down

0 comments on commit fac25a0

Please sign in to comment.