add more issue / pr creation params #331

Merged
6543 merged 18 commits from noerw/tea:issue-create-opts into master 2021-03-08 11:48:04 +00:00
2 changed files with 10 additions and 5 deletions
Showing only changes of commit 3e597e613a - Show all commits

View File

@ -62,12 +62,13 @@ func CreateIssue(login *config.Login, owner, repo string) error {
}
// check for custom value & prompt again with text input
// HACK until https://github.com/AlecAivazis/survey/issues/339 is implemented
if utils.Contains(assignees, customVal) {
if otherIndex := utils.IndexOf(assignees, customVal); otherIndex != -1 {
var customAssignees string
promptA := &survey.Input{Message: "Assignees:", Help: "comma separated usernames"}
if err := survey.AskOne(promptA, &customAssignees); err != nil {
return err
}
assignees = append(assignees[:otherIndex], assignees[otherIndex+1:]...)
assignees = append(assignees, strings.Split(customAssignees, ",")...)
}

View File

@ -6,11 +6,15 @@ package utils
// Contains checks containment
func Contains(haystack []string, needle string) bool {
for _, s := range haystack {
return IndexOf(haystack, needle) != -1
}
// IndexOf returns the index of first occurence of needle in haystack
func IndexOf(haystack []string, needle string) int {
for i, s := range haystack {
if s == needle {
return true
return i
}
}
return false
return -1
}