Skip to content

Commit

Permalink
Use first option as default option if none passed (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyx authored Mar 24, 2021
1 parent b518b64 commit 993837a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/cli/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ func ask(cmd *cobra.Command, i commandInput, value interface{}, defaultValue *st

func _select(cmd *cobra.Command, i commandInput, value interface{}, options []string, defaultValue *string, isUpdate bool) error {
isRequired := !isUpdate && i.GetIsRequired()

// If there is no provided default value, we'll use the first option in
// the selector by default.
if defaultValue == nil && len(options) > 0 {
defaultValue = &(options[0])
}

input := prompt.SelectInput("", i.GetLabel(), i.GetHelp(), options, auth0.StringValue(defaultValue), isRequired)

if err := prompt.AskOne(input, value); err != nil {
Expand Down

0 comments on commit 993837a

Please sign in to comment.