From efeb98f2f67cd04d6c3488fd738bbf5c36ee59ef Mon Sep 17 00:00:00 2001 From: Rita Zerrizuela Date: Fri, 9 Jul 2021 22:59:06 -0300 Subject: [PATCH] Fix askManyFlag --- internal/cli/apis.go | 12 ++++-------- internal/cli/apps.go | 16 ++++++++-------- internal/cli/flags.go | 12 +++++++----- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/internal/cli/apis.go b/internal/cli/apis.go index e8d5fc8c2..c9278776d 100644 --- a/internal/cli/apis.go +++ b/internal/cli/apis.go @@ -185,10 +185,8 @@ auth0 apis create -n myapi -e 6100 --offline-access=true`, return err } - if !apiScopes.IsSet(cmd) { - if err := apiScopes.AskMany(cmd, &inputs.Scopes, nil); err != nil { - return err - } + if err := apiScopes.AskMany(cmd, &inputs.Scopes, nil); err != nil { + return err } defaultTokenLifetime := strconv.Itoa(apiDefaultTokenLifetime()) @@ -281,10 +279,8 @@ auth0 apis update -n myapi -e 6100 --offline-access=true`, return err } - if !apiScopes.IsSet(cmd) { - if err := apiScopes.AskManyU(cmd, &inputs.Scopes, nil); err != nil { - return err - } + if err := apiScopes.AskManyU(cmd, &inputs.Scopes, nil); err != nil { + return err } currentTokenLifetime := strconv.Itoa(auth0.IntValue(current.TokenLifetime)) diff --git a/internal/cli/apps.go b/internal/cli/apps.go index a04b1d1af..c7e9b0740 100644 --- a/internal/cli/apps.go +++ b/internal/cli/apps.go @@ -351,7 +351,7 @@ auth0 apps create -n myapp -t [native|spa|regular|m2m] --description -n myapp --type [native|spa|regular|m2m]`, appIsSPA := apiTypeFor(inputs.Type) == appTypeSPA // Prompt for callback URLs if app is not m2m - if !appIsM2M && !appCallbacks.IsSet(cmd) { + if !appIsM2M { var defaultValue string if !appIsNative { @@ -529,7 +529,7 @@ auth0 apps update -n myapp --type [native|spa|regular|m2m]`, } // Prompt for logout URLs if app is not m2m - if !appIsM2M && !appLogoutURLs.IsSet(cmd) { + if !appIsM2M { var defaultValue string if !appIsNative { @@ -546,7 +546,7 @@ auth0 apps update -n myapp --type [native|spa|regular|m2m]`, } // Prompt for allowed origins URLs if app is SPA - if appIsSPA && !appOrigins.IsSet(cmd) { + if appIsSPA { defaultValue := appDefaultURL if len(current.AllowedOrigins) > 0 { @@ -559,7 +559,7 @@ auth0 apps update -n myapp --type [native|spa|regular|m2m]`, } // Prompt for allowed web origins URLs if app is SPA - if appIsSPA && !appWebOrigins.IsSet(cmd) { + if appIsSPA { defaultValue := appDefaultURL if len(current.WebOrigins) > 0 { diff --git a/internal/cli/flags.go b/internal/cli/flags.go index 35ff6a7e7..e17039cc5 100644 --- a/internal/cli/flags.go +++ b/internal/cli/flags.go @@ -193,13 +193,15 @@ func askFlag(cmd *cobra.Command, f *Flag, value interface{}, defaultValue *strin } func askManyFlag(cmd *cobra.Command, f *Flag, value interface{}, defaultValue *string, isUpdate bool) error { - var strInput string + if shouldAsk(cmd, f, isUpdate) { + var strInput string - if err := askFlag(cmd, f, &strInput, defaultValue, isUpdate); err != nil { - return err - } + if err := ask(cmd, f, &strInput, defaultValue, isUpdate); err != nil { + return err + } - *value.(*[]string) = commaSeparatedStringToSlice(strInput) + *value.(*[]string) = commaSeparatedStringToSlice(strInput) + } return nil }