prompter for projects
This commit is contained in:
parent
81cbf5e9b6
commit
00c25a8d62
2 changed files with 12 additions and 25 deletions
|
|
@ -7,7 +7,6 @@ import (
|
|||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/cli/cli/v2/pkg/prompt"
|
||||
)
|
||||
|
|
@ -260,15 +259,13 @@ func MetadataSurvey(p Prompt, io *iostreams.IOStreams, baseRepo ghrepo.Interface
|
|||
var mqs []*survey.Question
|
||||
if isChosen("Projects") {
|
||||
if len(projects) > 0 {
|
||||
mqs = append(mqs, &survey.Question{
|
||||
Name: "projects",
|
||||
Prompt: &survey.MultiSelect{
|
||||
Message: "Projects",
|
||||
Options: projects,
|
||||
Default: state.Projects,
|
||||
Filter: prompter.LatinMatchingFilter,
|
||||
},
|
||||
})
|
||||
selected, err := p.MultiSelect("Projects", state.Projects, projects)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, i := range selected {
|
||||
values.Projects = append(values.Projects, projects[i])
|
||||
}
|
||||
} else {
|
||||
fmt.Fprintln(io.ErrOut, "warning: no projects to choose from")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ func TestMetadataSurvey_selectAll(t *testing.T) {
|
|||
pm.RegisterMultiSelect("Labels", []string{}, []string{"help wanted", "good first issue"}, func(_ string, _, _ []string) ([]int, error) {
|
||||
return []int{1}, nil
|
||||
})
|
||||
pm.RegisterMultiSelect("Projects", []string{}, []string{"Huge Refactoring", "The road to 1.0"}, func(_ string, _, _ []string) ([]int, error) {
|
||||
return []int{1}, nil
|
||||
})
|
||||
|
||||
//nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber
|
||||
as, restoreAsk := prompt.InitAskStubber()
|
||||
|
|
@ -65,10 +68,6 @@ func TestMetadataSurvey_selectAll(t *testing.T) {
|
|||
|
||||
//nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt
|
||||
as.Stub([]*prompt.QuestionStub{
|
||||
{
|
||||
Name: "projects",
|
||||
Value: []string{"The road to 1.0"},
|
||||
},
|
||||
{
|
||||
Name: "milestone",
|
||||
Value: "(none)",
|
||||
|
|
@ -117,17 +116,8 @@ func TestMetadataSurvey_keepExisting(t *testing.T) {
|
|||
pm.RegisterMultiSelect("Labels", []string{}, []string{"help wanted", "good first issue"}, func(_ string, _, _ []string) ([]int, error) {
|
||||
return []int{1}, nil
|
||||
})
|
||||
|
||||
//nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber
|
||||
as, restoreAsk := prompt.InitAskStubber()
|
||||
defer restoreAsk()
|
||||
|
||||
//nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt
|
||||
as.Stub([]*prompt.QuestionStub{
|
||||
{
|
||||
Name: "projects",
|
||||
Value: []string{"The road to 1.0"},
|
||||
},
|
||||
pm.RegisterMultiSelect("Projects", []string{}, []string{"Huge Refactoring", "The road to 1.0"}, func(_ string, _, _ []string) ([]int, error) {
|
||||
return []int{1}, nil
|
||||
})
|
||||
|
||||
state := &IssueMetadataState{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue