-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
affects `project convert`, `tenant clone` and `tenant connect`
affects role select/add
// if there are no options to render | ||
if len(m.Options) == 0 { | ||
// we failed | ||
return "", errors.New("please provide options to select from") | ||
} | ||
|
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
fixes: #207
before:
after:
before:
after: