diff --git a/internal/cli/apis.go b/internal/cli/apis.go index 07b7bb49e..1aa35cc8c 100644 --- a/internal/cli/apis.go +++ b/internal/cli/apis.go @@ -129,9 +129,6 @@ func showApiCmd(cli *cli) *cobra.Command { Long: "Show an API.", Example: `auth0 apis show auth0 apis show `, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { err := apiID.Pick(cmd, &inputs.ID, cli.apiPickerOptions) @@ -179,9 +176,6 @@ auth0 apis create --name myapi auth0 apis create -n myapi --identifier http://my-api auth0 apis create -n myapi --token-expiration 6100 auth0 apis create -n myapi -e 6100 --offline-access=true`, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if err := apiName.Ask(cmd, &inputs.Name, nil); err != nil { return err @@ -253,9 +247,6 @@ auth0 apis update auth0 apis update --name myapi auth0 apis update -n myapi --token-expiration 6100 auth0 apis update -n myapi -e 6100 --offline-access=true`, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { var current *management.ResourceServer @@ -350,9 +341,6 @@ func deleteApiCmd(cli *cli) *cobra.Command { Long: "Delete an API.", Example: `auth0 apis delete auth0 apis delete `, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { err := apiID.Pick(cmd, &inputs.ID, cli.apiPickerOptions) @@ -396,9 +384,6 @@ func openApiCmd(cli *cli) *cobra.Command { Long: "Open API settings page in Auth0 Manage.", Example: `auth0 apis open auth0 apis open `, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { err := apiID.Pick(cmd, &inputs.ID, cli.apiPickerOptions) @@ -449,9 +434,6 @@ func listScopesCmd(cli *cli) *cobra.Command { Long: "List the scopes of an API.", Example: `auth0 apis scopes list auth0 apis scopes ls `, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { err := apiID.Pick(cmd, &inputs.ID, cli.apiPickerOptions) diff --git a/internal/cli/apps.go b/internal/cli/apps.go index f5e67b3d3..44db03163 100644 --- a/internal/cli/apps.go +++ b/internal/cli/apps.go @@ -151,10 +151,6 @@ func useAppCmd(cli *cli) *cobra.Command { Short: "Choose a default application for the Auth0 CLI", Long: "Specify your preferred application for interaction with the Auth0 CLI.", Example: "auth0 apps use ", - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, - RunE: func(cmd *cobra.Command, args []string) error { if inputs.None { inputs.ID = "" @@ -229,9 +225,6 @@ func showAppCmd(cli *cli) *cobra.Command { Long: "Show an application.", Example: `auth0 apps show auth0 apps show `, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { err := appID.Pick(cmd, &inputs.ID, cli.appPickerOptions) @@ -273,9 +266,6 @@ func deleteAppCmd(cli *cli) *cobra.Command { Long: "Delete an application.", Example: `auth0 apps delete auth0 apps delete `, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { err := appID.Pick(cmd, &inputs.ID, cli.appPickerOptions) @@ -331,9 +321,6 @@ func createAppCmd(cli *cli) *cobra.Command { auth0 apps create --name myapp auth0 apps create -n myapp --type [native|spa|regular|m2m] auth0 apps create -n myapp -t [native|spa|regular|m2m] -- description `, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { // Prompt for app name if err := appName.Ask(cmd, &inputs.Name, nil); err != nil { @@ -480,9 +467,6 @@ func updateAppCmd(cli *cli) *cobra.Command { Example: `auth0 apps update auth0 apps update --name myapp auth0 apps update -n myapp --type [native|spa|regular|m2m]`, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { var current *management.Client @@ -674,9 +658,6 @@ func openAppCmd(cli *cli) *cobra.Command { Short: "Open application settings page in Auth0 Manage", Long: "Open application settings page in Auth0 Manage.", Example: "auth0 apps open ", - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { err := appID.Pick(cmd, &inputs.ID, cli.appPickerOptions) diff --git a/internal/cli/logs.go b/internal/cli/logs.go index ba7efd0ff..74573329d 100644 --- a/internal/cli/logs.go +++ b/internal/cli/logs.go @@ -55,9 +55,6 @@ func listLogsCmd(cli *cli) *cobra.Command { Example: `auth0 logs list auth0 logs list --client-id auth0 logs ls -n 100`, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { list, err := getLatestLogs(cli, inputs.Num, inputs.ClientID) if err != nil { @@ -105,9 +102,6 @@ func tailLogsCmd(cli *cli) *cobra.Command { Example: `auth0 logs tail auth0 logs tail --client-id auth0 logs tail -n 100`, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { lastLogID := "" list, err := getLatestLogs(cli, inputs.Num, inputs.ClientID) diff --git a/internal/cli/quickstarts.go b/internal/cli/quickstarts.go index c83a16a72..605dbf00d 100644 --- a/internal/cli/quickstarts.go +++ b/internal/cli/quickstarts.go @@ -112,9 +112,6 @@ func downloadQuickstartCmd(cli *cli) *cobra.Command { Long: "Download a Quickstart sample app for a specific tech stack.", Example: `auth0 quickstarts download --stack auth0 qs download --stack `, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if !canPrompt(cmd) { return errors.New("This command can only be run on interactive mode") diff --git a/internal/cli/root.go b/internal/cli/root.go index c8ba573ee..c98424a40 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -62,6 +62,8 @@ func Execute() { ansi.DisableColors = cli.noColor + prepareInteractivity(cmd) + // Initialize everything once. Later callers can then // freely assume that config is fully primed and ready // to go. diff --git a/internal/cli/rules.go b/internal/cli/rules.go index 68000acea..f658cee1e 100644 --- a/internal/cli/rules.go +++ b/internal/cli/rules.go @@ -127,9 +127,6 @@ func createRuleCmd(cli *cli) *cobra.Command { auth0 rules create --name "My Rule" auth0 rules create -n "My Rule" --template "Empty rule" auth0 rules create -n "My Rule" -t "Empty rule" --enabled=false`, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if err := ruleName.Ask(cmd, &inputs.Name, nil); err != nil { return err @@ -191,9 +188,6 @@ func showRuleCmd(cli *cli) *cobra.Command { Long: "Show a rule.", Example: `auth0 rules show auth0 rules show `, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) > 0 { inputs.ID = args[0] @@ -236,9 +230,6 @@ func deleteRuleCmd(cli *cli) *cobra.Command { Long: "Delete a rule.", Example: `auth0 rules delete auth0 rules delete `, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) > 0 { inputs.ID = args[0] @@ -286,9 +277,6 @@ func updateRuleCmd(cli *cli) *cobra.Command { Example: `auth0 rules update auth0 rules update --name "My Updated Rule" auth0 rules update -n "My Updated Rule" --enabled=false`, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) > 0 { inputs.ID = args[0] @@ -380,9 +368,6 @@ func enableRuleCmd(cli *cli) *cobra.Command { Short: "Enable a rule", Long: "Enable a rule.", Example: `auth0 rules enable `, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) > 0 { inputs.ID = args[0] @@ -435,9 +420,6 @@ func disableRuleCmd(cli *cli) *cobra.Command { Short: "Disable a rule", Long: "Disable a rule.", Example: `auth0 rules disable `, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) > 0 { inputs.ID = args[0] diff --git a/internal/cli/template.go b/internal/cli/template.go index 9b8eeabb3..772e96191 100644 --- a/internal/cli/template.go +++ b/internal/cli/template.go @@ -83,9 +83,6 @@ func updateBrandingTemplateCmd(cli *cli) *cobra.Command { Short: "Update the custom template for Universal Login", Long: "Update the custom template for Universal Login.", Example: "auth0 branding templates update", - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { var templateData *branding.TemplateData err := ansi.Waiting(func() error { diff --git a/internal/cli/tenants.go b/internal/cli/tenants.go index ad1f4cf1b..8931fbdf6 100644 --- a/internal/cli/tenants.go +++ b/internal/cli/tenants.go @@ -61,9 +61,6 @@ func useTenantCmd(cli *cli) *cobra.Command { Short: "Set the active tenant", Long: "Set the active tenant.", Example: "auth0 tenants use ", - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { var selectedTenant string if len(args) == 0 { @@ -113,9 +110,6 @@ func openTenantCmd(cli *cli) *cobra.Command { Short: "Open tenant settings page in Auth0 Manage", Long: "Open tenant settings page in Auth0 Manage.", Example: "auth0 tenants open ", - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { err := tenantDomain.Pick(cmd, &inputs.Domain, cli.tenantPickerOptions) diff --git a/internal/cli/users.go b/internal/cli/users.go index 2d66a6156..3af6d1f52 100644 --- a/internal/cli/users.go +++ b/internal/cli/users.go @@ -44,16 +44,11 @@ func listUserBlocksCmd(cli *cli) *cobra.Command { } cmd := &cobra.Command{ - Use: "list", - Args: cobra.MaximumNArgs(1), - Short: "List brute-force protection blocks for a given user", - Long: `List brute-force protection blocks for a given user: - -auth0 users blocks list -`, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, + Use: "list", + Args: cobra.MaximumNArgs(1), + Short: "List brute-force protection blocks for a given user", + Long: "List brute-force protection blocks for a given user.", + Example: "auth0 users blocks list ", RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { if err := userID.Ask(cmd, &inputs.userID); err != nil { @@ -89,16 +84,11 @@ func deleteUserBlocksCmd(cli *cli) *cobra.Command { } cmd := &cobra.Command{ - Use: "unblock", - Args: cobra.MaximumNArgs(1), - Short: "Delete brute-force protection blocks for a given user", - Long: `Delete brute-force protection blocks for a given user: - -auth0 users unblock -`, - PreRun: func(cmd *cobra.Command, args []string) { - prepareInteractivity(cmd) - }, + Use: "unblock", + Args: cobra.MaximumNArgs(1), + Short: "Remove brute-force protection blocks for a given user", + Long: "Remove brute-force protection blocks for a given user.", + Example: "auth0 users unblock ", RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { if err := userID.Ask(cmd, &inputs.userID); err != nil {