From 69bfae0e297d12b4f6863283ed6fcabc4be80630 Mon Sep 17 00:00:00 2001 From: Cyril David Date: Fri, 5 Mar 2021 00:03:20 -0800 Subject: [PATCH] actions show: use key value list Also standardize on JSON output as well similar to apis. --- internal/cli/actions.go | 14 ++++++------- internal/display/actions.go | 39 +++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/internal/cli/actions.go b/internal/cli/actions.go index ab588c713..a0ee593a6 100644 --- a/internal/cli/actions.go +++ b/internal/cli/actions.go @@ -119,7 +119,7 @@ func testActionCmd(cli *cli) *cobra.Command { Use: "test", Args: cobra.MaximumNArgs(1), Short: "Test an action draft against a payload", - Long: `Test an action draft against a payload: + Long: `Test an action draft against a payload: auth0 actions test --file payload.json`, PreRun: func(cmd *cobra.Command, args []string) { @@ -193,8 +193,8 @@ func deployActionCmd(cli *cli) *cobra.Command { Use: "deploy", Args: cobra.MaximumNArgs(1), Short: "Deploy the action version", - Long: `Deploy the action version: - + Long: `Deploy the action version: + auth0 actions deploy --version version-id`, PreRun: func(cmd *cobra.Command, args []string) { prepareInteractivity(cmd) @@ -290,7 +290,7 @@ func downloadActionCmd(cli *cli) *cobra.Command { Use: "download", Args: cobra.MaximumNArgs(1), Short: "Download an action", - Long: `Download an action: + Long: `Download an action: auth0 actions download --version `, PreRun: func(cmd *cobra.Command, args []string) { @@ -383,7 +383,7 @@ func listActionVersionsCmd(cli *cli) *cobra.Command { Use: "versions", Args: cobra.MaximumNArgs(1), Short: "List the action versions", - Long: `List the action versions: + Long: `List the action versions: auth0 actions versions `, PreRun: func(cmd *cobra.Command, args []string) { @@ -756,7 +756,7 @@ func updateFlowCmd(cli *cli) *cobra.Command { Use: "update", Args: cobra.MaximumNArgs(1), Short: "Update actions by flow", - Long: `Update actions by flow: + Long: `Update actions by flow: auth0 actions flows update --file bindings.json`, PreRun: func(cmd *cobra.Command, args []string) { @@ -837,7 +837,7 @@ func bindActionCmd(cli *cli) *cobra.Command { Use: "bind", Args: cobra.MaximumNArgs(1), Short: "Bind an action to a flow", - Long: `Bind an action to a flow: + Long: `Bind an action to a flow: auth0 actions bind --trigger post-login`, PreRun: func(cmd *cobra.Command, args []string) { diff --git a/internal/display/actions.go b/internal/display/actions.go index d1c6c45ae..63bc64d72 100644 --- a/internal/display/actions.go +++ b/internal/display/actions.go @@ -14,6 +14,7 @@ type actionView struct { Name string CreatedAt string Type string + raw interface{} } func (v *actionView) AsTableHeader() []string { @@ -24,6 +25,19 @@ func (v *actionView) AsTableRow() []string { return []string{v.ID, v.Name, v.Type, v.CreatedAt} } +func (v *actionView) KeyValues() [][]string { + return [][]string{ + []string{"ID", v.ID}, + []string{"NAME", v.Name}, + []string{"TYPE", v.Type}, + []string{"CREATED AT", v.CreatedAt}, + } +} + +func (v *actionView) Object() interface{} { + return v.raw +} + type triggerView struct { ID string ActionID string @@ -47,6 +61,8 @@ type actionVersionView struct { Status string Deployed string CreatedAt string + + raw interface{} } func (v *actionVersionView) AsTableHeader() []string { @@ -57,6 +73,23 @@ func (v *actionVersionView) AsTableRow() []string { return []string{v.Number, v.getID(), v.ActionID, v.ActionName, v.Runtime, v.Status, v.CreatedAt, v.Deployed} } +func (v *actionVersionView) KeyValues() [][]string { + return [][]string{ + []string{"Number", v.Number}, + []string{"ID", v.getID()}, + []string{"ActionID", v.ActionID}, + []string{"ActionName", v.ActionName}, + []string{"RUNTIME", v.ActionName}, + []string{"STATUS", v.Status}, + []string{"CREATED AT", v.CreatedAt}, + []string{"DEPLOYED", v.Deployed}, + } +} + +func (v *actionVersionView) Object() interface{} { + return v.raw +} + func (v *actionVersionView) getID() string { // draft versions don't have a unique id if v.ID == "" { @@ -78,9 +111,9 @@ func (r *Renderer) ActionList(actions []*management.Action) { res = append(res, &actionView{ ID: auth0.StringValue(a.ID), Name: auth0.StringValue(a.Name), - CreatedAt: timeAgo(auth0.TimeValue(a.CreatedAt)), Type: strings.Join(triggers, ", "), - // Runtime: auth0.StringValue(a.Runtime), + CreatedAt: timeAgo(auth0.TimeValue(a.CreatedAt)), + raw: a, }) } @@ -106,6 +139,7 @@ func (r *Renderer) Action(action *management.Action) { Name: auth0.StringValue(action.Name), CreatedAt: timeAgo(auth0.TimeValue(action.CreatedAt)), Type: strings.Join(triggers, ", "), + raw: action, } r.Results([]View{v}) @@ -142,6 +176,7 @@ func ActionVersionView(version *management.ActionVersion) *actionVersionView { Status: string(version.Status), Deployed: deployed, CreatedAt: timeAgo(auth0.TimeValue(version.CreatedAt)), + raw: version, } }