Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix askManyFlag #331

Merged
merged 4 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions internal/cli/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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))
Expand Down
16 changes: 8 additions & 8 deletions internal/cli/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ auth0 apps create -n myapp -t [native|spa|regular|m2m] --description <descriptio
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 {
Expand All @@ -364,7 +364,7 @@ auth0 apps create -n myapp -t [native|spa|regular|m2m] --description <descriptio
}

// Prompt for logout URLs if app is not m2m
if !appIsM2M && !appLogoutURLs.IsSet(cmd) {
if !appIsM2M {
var defaultValue string

if !appIsNative {
Expand All @@ -377,7 +377,7 @@ auth0 apps create -n myapp -t [native|spa|regular|m2m] --description <descriptio
}

// Prompt for allowed origins URLs if app is SPA
if appIsSPA && !appOrigins.IsSet(cmd) {
if appIsSPA {
defaultValue := appDefaultURL

if err := appOrigins.AskMany(cmd, &inputs.AllowedOrigins, &defaultValue); err != nil {
Expand All @@ -386,7 +386,7 @@ auth0 apps create -n myapp -t [native|spa|regular|m2m] --description <descriptio
}

// Prompt for allowed web origins URLs if app is SPA
if appIsSPA && !appWebOrigins.IsSet(cmd) {
if appIsSPA {
defaultValue := appDefaultURL

if err := appWebOrigins.AskMany(cmd, &inputs.AllowedWebOrigins, &defaultValue); err != nil {
Expand Down Expand Up @@ -512,7 +512,7 @@ auth0 apps update <id> -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 {
Expand All @@ -529,7 +529,7 @@ auth0 apps update <id> -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 {
Expand All @@ -546,7 +546,7 @@ auth0 apps update <id> -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 {
Expand All @@ -559,7 +559,7 @@ auth0 apps update <id> -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 {
Expand Down
12 changes: 7 additions & 5 deletions internal/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,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
}
Expand Down