Skip to content

Commit

Permalink
apps show: use key value list
Browse files Browse the repository at this point in the history
Also standardize on JSON output as well similar to apis.
  • Loading branch information
cyx committed Mar 5, 2021
1 parent 6514e39 commit 161d60a
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion internal/display/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type applicationView struct {
ClientSecret string
Callbacks []string
revealSecret bool

raw interface{}
}

func (v *applicationView) AsTableHeader() []string {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand All @@ -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})
Expand All @@ -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})
Expand Down

0 comments on commit 161d60a

Please sign in to comment.