diff --git a/internal/cli/apps_test.go b/internal/cli/apps_test.go index c0624d33e..297dd3436 100644 --- a/internal/cli/apps_test.go +++ b/internal/cli/apps_test.go @@ -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"}, }, ) } diff --git a/internal/display/clients.go b/internal/display/apps.go similarity index 78% rename from internal/display/clients.go rename to internal/display/apps.go index ee20b36e3..ecc588ac6 100644 --- a/internal/display/clients.go +++ b/internal/display/apps.go @@ -17,7 +17,7 @@ const ( quickstartsGeneric = "https://auth0.com/docs/quickstarts" ) -type clientView struct { +type applicationView struct { Name string Type string ClientID string @@ -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, @@ -53,6 +52,40 @@ 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 @@ -60,12 +93,11 @@ func (r *Renderer) ApplicationList(clients []*management.Client) { 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), }) } @@ -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), @@ -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),