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

chore: add edit organization role to cli#13365

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 9 commits intomainfromstevenmasley/path_org_role_cli
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletioncli/cliui/parameter.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -43,7 +43,10 @@ func RichParameter(inv *serpent.Invocation, templateVersionParameter codersdk.Te
return "", err
}

values, err := MultiSelect(inv, options)
values, err := MultiSelect(inv, MultiSelectOptions{
Options: options,
Defaults: options,
})
if err == nil {
v, err := json.Marshal(&values)
if err != nil {
Expand Down
17 changes: 13 additions & 4 deletionscli/cliui/select.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,6 +56,7 @@ type SelectOptions struct {
Options []string
// Default will be highlighted first if it's a valid option.
Default string
Message string
Size int
HideSearch bool
}
Expand DownExpand Up@@ -122,6 +123,7 @@ func Select(inv *serpent.Invocation, opts SelectOptions) (string, error) {
Options: opts.Options,
Default: defaultOption,
PageSize: opts.Size,
Message: opts.Message,
}, &value, survey.WithIcons(func(is *survey.IconSet) {
is.Help.Text = "Type to search"
if opts.HideSearch {
Expand All@@ -138,15 +140,22 @@ func Select(inv *serpent.Invocation, opts SelectOptions) (string, error) {
return value, err
}

func MultiSelect(inv *serpent.Invocation, items []string) ([]string, error) {
type MultiSelectOptions struct {
Message string
Options []string
Defaults []string
}

func MultiSelect(inv *serpent.Invocation, opts MultiSelectOptions) ([]string, error) {
// Similar hack is applied to Select()
if flag.Lookup("test.v") != nil {
returnitems, nil
returnopts.Defaults, nil
}

prompt := &survey.MultiSelect{
Copy link
Member

@johnstcnjohnstcnMay 31, 2024
edited
Loading

Choose a reason for hiding this comment

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

The prompt doesn't explain the keybindings:

  • <space> to select
  • <enter> to submit and return to the previous list
  • <arrow keys> to navigate

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yup it does not. I added it as a note in the PR, just made it an issue:#13427

I talked to@mtojek about this, and I also see Kyle made some adjustments. Essentially, we cannot have different survey templates for different questions. They all share the same global. This global has all the things you mentioned and more. I'd like to revert our change as much as possible, but I'll have to probably adjust every instance that we use this and make sure I did not break anything.

Feels excessive for this PR imo.

Options: items,
Default: items,
Options: opts.Options,
Default: opts.Defaults,
Message: opts.Message,
}

var values []string
Expand Down
5 changes: 4 additions & 1 deletioncli/cliui/select_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,10 @@ func newMultiSelect(ptty *ptytest.PTY, items []string) ([]string, error) {
var values []string
cmd := &serpent.Command{
Handler: func(inv *serpent.Invocation) error {
selectedItems, err := cliui.MultiSelect(inv, items)
selectedItems, err := cliui.MultiSelect(inv, cliui.MultiSelectOptions{
Options: items,
Defaults: items,
})
if err == nil {
values = selectedItems
}
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp