Skip to content

Commit

Permalink
Add spinner and massage command help message
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Kulash committed Jan 25, 2021
1 parent 04a86b7 commit 000995e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/cli/rules.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"github.com/auth0/auth0-cli/internal/ansi"
"github.com/spf13/cobra"
"gopkg.in/auth0.v5/management"
)
Expand Down Expand Up @@ -49,10 +50,15 @@ func createRulesCmd(cli *cli) *cobra.Command {
order int
enabled bool
}

cmd := &cobra.Command{
Use: "create",
Short: "Create a new rule",
Long: "Create a new rule in your current tenant.",
Long: `Create a new rule:
auth0 rules create --name "My Rule" --script "function (user, context, callback) { console.log( 'Hello, world!' ); return callback(null, user, context); }"
`,
Args: cobra.MinimumNArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
r := &management.Rule{
Name: &flags.name,
Expand All @@ -61,7 +67,9 @@ func createRulesCmd(cli *cli) *cobra.Command {
Enabled: &flags.enabled,
}

err := cli.api.Client.Rule.Create(r)
err := ansi.Spinner("Creating rule", func() error {
return cli.api.Client.Rule.Create(r)
})

if err != nil {
return err
Expand Down

0 comments on commit 000995e

Please sign in to comment.