Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit973cc2b

Browse files
authored
chore: add edit organization role to cli (#13365)
Editing custom org roles from hidden org cli command.
1 parent24ba819 commit973cc2b

File tree

8 files changed

+484
-23
lines changed

8 files changed

+484
-23
lines changed

‎cli/cliui/parameter.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ func RichParameter(inv *serpent.Invocation, templateVersionParameter codersdk.Te
4343
return"",err
4444
}
4545

46-
values,err:=MultiSelect(inv,options)
46+
values,err:=MultiSelect(inv,MultiSelectOptions{
47+
Options:options,
48+
Defaults:options,
49+
})
4750
iferr==nil {
4851
v,err:=json.Marshal(&values)
4952
iferr!=nil {

‎cli/cliui/select.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type SelectOptions struct {
5656
Options []string
5757
// Default will be highlighted first if it's a valid option.
5858
Defaultstring
59+
Messagestring
5960
Sizeint
6061
HideSearchbool
6162
}
@@ -122,6 +123,7 @@ func Select(inv *serpent.Invocation, opts SelectOptions) (string, error) {
122123
Options:opts.Options,
123124
Default:defaultOption,
124125
PageSize:opts.Size,
126+
Message:opts.Message,
125127
},&value,survey.WithIcons(func(is*survey.IconSet) {
126128
is.Help.Text="Type to search"
127129
ifopts.HideSearch {
@@ -138,15 +140,22 @@ func Select(inv *serpent.Invocation, opts SelectOptions) (string, error) {
138140
returnvalue,err
139141
}
140142

141-
funcMultiSelect(inv*serpent.Invocation,items []string) ([]string,error) {
143+
typeMultiSelectOptionsstruct {
144+
Messagestring
145+
Options []string
146+
Defaults []string
147+
}
148+
149+
funcMultiSelect(inv*serpent.Invocation,optsMultiSelectOptions) ([]string,error) {
142150
// Similar hack is applied to Select()
143151
ifflag.Lookup("test.v")!=nil {
144-
returnitems,nil
152+
returnopts.Defaults,nil
145153
}
146154

147155
prompt:=&survey.MultiSelect{
148-
Options:items,
149-
Default:items,
156+
Options:opts.Options,
157+
Default:opts.Defaults,
158+
Message:opts.Message,
150159
}
151160

152161
varvalues []string

‎cli/cliui/select_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ func newMultiSelect(ptty *ptytest.PTY, items []string) ([]string, error) {
107107
varvalues []string
108108
cmd:=&serpent.Command{
109109
Handler:func(inv*serpent.Invocation)error {
110-
selectedItems,err:=cliui.MultiSelect(inv,items)
110+
selectedItems,err:=cliui.MultiSelect(inv, cliui.MultiSelectOptions{
111+
Options:items,
112+
Defaults:items,
113+
})
111114
iferr==nil {
112115
values=selectedItems
113116
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp