From 161d60ac35170c3c975f86287aab44493f7ee26f Mon Sep 17 00:00:00 2001 From: Cyril David Date: Thu, 4 Mar 2021 23:54:08 -0800 Subject: [PATCH] apps show: use key value list Also standardize on JSON output as well similar to apis. --- internal/display/apps.go | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/internal/display/apps.go b/internal/display/apps.go index b705cc9e1..797a13242 100644 --- a/internal/display/apps.go +++ b/internal/display/apps.go @@ -24,6 +24,8 @@ type applicationView struct { ClientSecret string Callbacks []string revealSecret bool + + raw interface{} } func (v *applicationView) AsTableHeader() []string { @@ -51,6 +53,32 @@ func (v *applicationView) AsTableRow() []string { } } +func (v *applicationView) KeyValues() [][]string { + callbacks := strings.Join(v.Callbacks, ", ") + + if v.revealSecret { + return [][]string{ + []string{"NAME", v.Name}, + []string{"TYPE", v.Type}, + []string{"CLIENT ID", ansi.Faint(v.ClientID)}, + []string{"CLIENT SECRET", ansi.Italic(v.ClientSecret)}, + []string{"CALLBACKS", callbacks}, + } + + } + + return [][]string{ + []string{"NAME", v.Name}, + []string{"TYPE", v.Type}, + []string{"CLIENT ID", ansi.Faint(v.ClientID)}, + []string{"CALLBACKS", callbacks}, + } +} + +func (v *applicationView) Object() interface{} { + return v.raw +} + // applicationListView is a slimmed down view of a client for displaying // larger numbers of applications type applicationListView struct { @@ -113,9 +141,10 @@ func (r *Renderer) ApplicationShow(client *management.Client, revealSecrets bool ClientID: auth0.StringValue(client.ClientID), ClientSecret: auth0.StringValue(client.ClientSecret), Callbacks: callbacksFor(client.Callbacks), + raw: client, } - r.Results([]View{v}) + r.Result(v) } func (r *Renderer) ApplicationCreate(client *management.Client, revealSecrets bool) { @@ -128,6 +157,7 @@ func (r *Renderer) ApplicationCreate(client *management.Client, revealSecrets bo ClientID: auth0.StringValue(client.ClientID), ClientSecret: auth0.StringValue(client.ClientSecret), Callbacks: callbacksFor(client.Callbacks), + raw: client, } r.Results([]View{v}) @@ -145,6 +175,7 @@ func (r *Renderer) ApplicationUpdate(client *management.Client, revealSecrets bo ClientID: auth0.StringValue(client.ClientID), ClientSecret: auth0.StringValue(client.ClientSecret), Callbacks: callbacksFor(client.Callbacks), + raw: client, } r.Results([]View{v})