Skip to content

Commit c39c0dc

Browse files
authored
fix: select default option value (#7152)
1 parent 285646b commit c39c0dc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cli/cliui/select.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,22 @@ type RichSelectOptions struct {
7070
// RichSelect displays a list of user options including name and description.
7171
func RichSelect(inv *clibase.Invocation, richOptions RichSelectOptions) (*codersdk.TemplateVersionParameterOption, error) {
7272
opts := make([]string, len(richOptions.Options))
73+
var defaultOpt string
7374
for i, option := range richOptions.Options {
7475
line := option.Name
7576
if len(option.Description) > 0 {
7677
line += ": " + option.Description
7778
}
7879
opts[i] = line
80+
81+
if option.Value == richOptions.Default {
82+
defaultOpt = line
83+
}
7984
}
8085

8186
selected, err := Select(inv, SelectOptions{
8287
Options: opts,
83-
Default: richOptions.Default,
88+
Default: defaultOpt,
8489
Size: richOptions.Size,
8590
HideSearch: richOptions.HideSearch,
8691
})

0 commit comments

Comments
 (0)