From 993837a69e7a8b5d0ca6c3df75af9e1d4054977d Mon Sep 17 00:00:00 2001 From: Cyril David Date: Wed, 24 Mar 2021 11:30:52 -0700 Subject: [PATCH] Use first option as default option if none passed (#186) --- internal/cli/input.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/cli/input.go b/internal/cli/input.go index 7111bbbe1..4bf1e9d8c 100644 --- a/internal/cli/input.go +++ b/internal/cli/input.go @@ -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 {