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: empty list errors #208

Merged
merged 3 commits into from
Jan 6, 2023
Merged

Fix: empty list errors #208

merged 3 commits into from
Jan 6, 2023

Conversation

benPearce1
Copy link
Contributor

fixes: #207

before:
image

after:
image

before:
image

after:
image

Comment on lines -268 to -273
// if there are no options to render
if len(m.Options) == 0 {
// we failed
return "", errors.New("please provide options to select from")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this copy of the multi-select is specifically designed to allow adding new entries, an empty starting list should not be an error


"github.com/AlecAivazis/survey/v2"
"github.com/OctopusDeploy/cli/pkg/constants"
"github.com/OctopusDeploy/cli/pkg/surveyext"
)

func MultiSelectMap[T any](ask Asker, message string, items []T, getKey func(item T) string, required bool) ([]T, error) {
if util.Empty(items) {
return nil, fmt.Errorf("%s - no options available", message)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by erroring with the original prompt, the user gets the context of the error

@benPearce1 benPearce1 marked this pull request as ready for review January 6, 2023 01:53
@benPearce1 benPearce1 requested a review from a team January 6, 2023 01:53
@benPearce1 benPearce1 merged commit 74cbfe2 into main Jan 6, 2023
@benPearce1 benPearce1 deleted the fix/empty-list-error branch January 6, 2023 03:01
This was referenced Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Select prompts error when there are no options
2 participants