Skip to content

feat: CLI use multiselect for list(string) #6631

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

Merged
merged 6 commits into from
Mar 16, 2023

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Mar 16, 2023

Related: #6582

This PR enables support for multiselect in CLI, so that coder can render rich parameter type list(string).

Screenshot 2023-03-16 at 13 08 10

@mtojek mtojek self-assigned this Mar 16, 2023
@mtojek mtojek marked this pull request as ready for review March 16, 2023 14:49
@mtojek mtojek marked this pull request as draft March 16, 2023 15:18
@mtojek
Copy link
Member Author

mtojek commented Mar 16, 2023

Back to draft, spotted a bug

@mtojek mtojek marked this pull request as ready for review March 16, 2023 15:39
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

I didn't test it, but it looks good. The tests seem a bit superficial to me, if I understand correctly. But if it's the same with Select then I don't have an objection. (Although perhaps both should be improved in the future.)

@@ -118,6 +133,29 @@ func Select(cmd *cobra.Command, opts SelectOptions) (string, error) {
return value, err
}

func MultiSelect(cmd *cobra.Command, items []string) ([]string, error) {
// Similar hack is applied to Select()
if flag.Lookup("test.v") != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, so it looks like we're not actually testing the multi select behavior with this hack?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I was surprised about it too, it just goes with the default. I wasn't able to properly simulate the user marking options.

@mtojek mtojek merged commit 1f9ae15 into coder:main Mar 16, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants