Skip to content

Commit

Permalink
Fix stack selection behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
aq17 committed Nov 18, 2022
1 parent befe190 commit fa273b4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/cmd/pulumi/util.go
Expand Up @@ -356,6 +356,8 @@ func chooseStack(ctx context.Context,
}

// If we are offering to create a new stack, add that to the end of the list.
// Otherwise, default to a stack if one exists – otherwise pressing enter will result in
// the empty string being passed (see https://github.com/go-survey/survey/issues/342).
const newOption = "<create a new stack>"
if offerNew {
options = append(options, newOption)
Expand All @@ -367,6 +369,8 @@ func chooseStack(ctx context.Context,
} else if len(options) == 0 {
// If no options are available, we can't offer a choice!
return nil, errors.New("this command requires a stack, but there are none")
} else if defaultOption == "" {
defaultOption = options[0]
}

// Customize the prompt a little bit (and disable color since it doesn't match our scheme).
Expand Down

0 comments on commit fa273b4

Please sign in to comment.