-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func actionsCmd(cli *cli) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "actions", | ||
Short: "manage resources for actions.", | ||
} | ||
|
||
cmd.SetUsageTemplate(resourceUsageTemplate()) | ||
cmd.AddCommand(listActionsCmd(cli)) | ||
|
||
return cmd | ||
} | ||
|
||
func listActionsCmd(cli *cli) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "list", | ||
Short: "Lists your existing actions", | ||
Long: `$ auth0 actions list | ||
Lists your existing actions. To create one try: | ||
$ auth0 actions create | ||
`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
list, err := cli.api.Action.List() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cli.renderer.ActionList(list.Actions) | ||
return nil | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package display | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/auth0/auth0-cli/internal/ansi" | ||
"gopkg.in/auth0.v5" | ||
"gopkg.in/auth0.v5/management" | ||
) | ||
|
||
type actionView struct { | ||
ID string | ||
Name string | ||
CreatedAt string | ||
Type string | ||
} | ||
|
||
func (v *actionView) AsTableHeader() []string { | ||
return []string{"ID", "Name", "Type", "CreatedAt"} | ||
} | ||
|
||
func (v *actionView) AsTableRow() []string { | ||
return []string{v.ID, v.Name, v.Type, v.CreatedAt} | ||
} | ||
|
||
func (r *Renderer) ActionList(actions []*management.Action) { | ||
r.Heading(ansi.Bold(r.Tenant), "actions\n") | ||
|
||
var res []View | ||
for _, a := range actions { | ||
var triggers = make([]string, 0, len(*a.SupportedTriggers)) | ||
for _, t := range *a.SupportedTriggers { | ||
triggers = append(triggers, string(*t.ID)) | ||
} | ||
|
||
res = append(res, &actionView{ | ||
ID: auth0.StringValue(a.ID), | ||
Name: auth0.StringValue(a.Name), | ||
CreatedAt: a.CreatedAt.String(), | ||
Type: strings.Join(triggers, ", "), | ||
// Runtime: auth0.StringValue(a.Runtime), | ||
}) | ||
|
||
} | ||
|
||
r.Results(res) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.