Skip to content

Commit

Permalink
(issue, state) add state flag for filtering issues by state
Browse files Browse the repository at this point in the history
  • Loading branch information
nkprince007 committed Dec 17, 2017
1 parent 40d3d31 commit c9ccd9b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/issueList.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

var issueLabels []string
var issueState string

var issueListCmd = &cobra.Command{
Use: "list",
Expand All @@ -36,7 +37,7 @@ var issueListCmd = &cobra.Command{
PerPage: 10,
},
Labels: issueLabels,
State: gitlab.String("opened"),
State: &issueState,
OrderBy: gitlab.String("updated_at"),
})
if err != nil {
Expand All @@ -51,5 +52,8 @@ var issueListCmd = &cobra.Command{
func init() {
issueListCmd.Flags().StringSliceVarP(
&issueLabels, "label", "l", []string{}, "filter issues by label")
issueListCmd.Flags().StringVarP(
&issueState, "state", "s", "opened",
"filter issues by state (opened/closed)")
issueCmd.AddCommand(issueListCmd)
}
15 changes: 15 additions & 0 deletions cmd/issueList_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,18 @@ func Test_issueListFlagLabel(t *testing.T) {
t.Log(issues)
require.Equal(t, "#3 test filter labels 1", issues[0])
}

func Test_issueListStateClosed(t *testing.T) {
repo := copyTestRepo(t)
cmd := exec.Command("../lab_bin", "issue", "list", "-s", "closed")
cmd.Dir = repo

b, err := cmd.CombinedOutput()
if err != nil {
t.Fatal(err)
}

issues := strings.Split(string(b), "\n")
t.Log(issues)
require.Equal(t, "#4 test closed issue", issues[0])
}

0 comments on commit c9ccd9b

Please sign in to comment.