Add mentioned flag

This commit is contained in:
Eddú Meléndez 2020-03-12 21:40:11 -06:00
parent 54e0534b1b
commit 2943703d4a
4 changed files with 20 additions and 9 deletions

View file

@ -41,6 +41,7 @@ func init() {
issueListCmd.Flags().StringP("state", "s", "open", "Filter by state: {open|closed|all}")
issueListCmd.Flags().IntP("limit", "L", 30, "Maximum number of issues to fetch")
issueListCmd.Flags().StringP("author", "A", "", "Filter by author")
issueListCmd.Flags().StringP("mentioned", "", "", "Filter by mention")
issueCmd.AddCommand(issueViewCmd)
issueViewCmd.Flags().BoolP("web", "w", false, "Open an issue in the browser")
@ -141,7 +142,12 @@ func issueList(cmd *cobra.Command, args []string) error {
return err
}
listResult, err := api.IssueList(apiClient, baseRepo, state, labels, assignee, limit, author)
mentioned, err := cmd.Flags().GetString("mentioned")
if err != nil {
return err
}
listResult, err := api.IssueList(apiClient, baseRepo, state, labels, assignee, limit, author, mentioned)
if err != nil {
return err
}

View file

@ -153,7 +153,7 @@ func TestIssueList_withFlags(t *testing.T) {
} } }
`))
output, err := RunCommand("issue list -a probablyCher -l web,bug -s open -A foo")
output, err := RunCommand("issue list -a probablyCher -l web,bug -s open -A foo --mentioned me")
if err != nil {
t.Errorf("error running command `issue list`: %v", err)
}
@ -167,10 +167,11 @@ No issues match your search in OWNER/REPO
bodyBytes, _ := ioutil.ReadAll(http.Requests[1].Body)
reqBody := struct {
Variables struct {
Assignee string
Labels []string
States []string
Author string
Assignee string
Labels []string
States []string
Author string
Mentioned string
}
}{}
_ = json.Unmarshal(bodyBytes, &reqBody)
@ -179,6 +180,7 @@ No issues match your search in OWNER/REPO
eq(t, reqBody.Variables.Labels, []string{"web", "bug"})
eq(t, reqBody.Variables.States, []string{"OPEN"})
eq(t, reqBody.Variables.Author, "foo")
eq(t, reqBody.Variables.Mentioned, "me")
}
func TestIssueList_withInvalidLimitFlag(t *testing.T) {