diff --git a/api/jira-api.go b/api/jira-api.go index 0af9a2d..6a69b5a 100644 --- a/api/jira-api.go +++ b/api/jira-api.go @@ -93,7 +93,7 @@ func GetIssue(key string) <-chan JiraIssue { return channel } -func GetIssueList(nResults int, all bool, reporter bool, project string, statuses []string, prioritySort bool) <-chan JiraIssue { +func GetIssueList(nResults int, all bool, reporter bool, project string, statuses []string, searchTerm string, prioritySort bool) <-chan JiraIssue { channel := make(chan JiraIssue) go func() { defer close(channel) @@ -111,6 +111,12 @@ func GetIssueList(nResults int, all bool, reporter bool, project string, statuse } query += fmt.Sprintf("project=%s", url.QueryEscape(project)) } + if searchTerm != "" { + if query != "" { + query += "+AND+" + } + query += fmt.Sprintf("summary~\"%s\"", url.QueryEscape(searchTerm)) + } if len(statuses) > 0 { if query != "" { query += "+AND+" diff --git a/cmd/issue/list.go b/cmd/issue/list.go index 323e5a5..0c75353 100644 --- a/cmd/issue/list.go +++ b/cmd/issue/list.go @@ -19,6 +19,7 @@ var ListCmd = &cobra.Command{ nResults, _ := cmd.Flags().GetInt("number-results") reporter, _ := cmd.Flags().GetBool("reporter") all, _ := cmd.Flags().GetBool("all") + search, _ := cmd.Flags().GetString("search") statuses, _ := cmd.Flags().GetStringArray("status") project, _ := cmd.Flags().GetString("project") priority, _ := cmd.Flags().GetBool("priority") @@ -50,7 +51,7 @@ var ListCmd = &cobra.Command{ } } - for issue := range api.GetIssueList(nResults, all, reporter, project, statusConversion, priority) { + for issue := range api.GetIssueList(nResults, all, reporter, project, statusConversion, search, priority) { timeSpent := "-" if issue.Fields.TimeTracking.TimeSpent != " " { timeSpent = issue.Fields.TimeTracking.TimeSpent @@ -74,6 +75,7 @@ var ListCmd = &cobra.Command{ } func init() { + // filter ListCmd.Flags().StringP("project", "p", "", `filter issues by project key. If "all" is given it shows all projects (when a project is detected on current branch and you still want to show all projects)`) ListCmd.Flags().BoolP("all", "a", false, "filter all issues. (Not assigned or reporting to current user)") @@ -81,6 +83,7 @@ func init() { ListCmd.Flags().StringArrayP("status", "s", []string{}, `filter status type. this option will provide completion for the mappings defined in "jira_status" of your config file`) ListCmd.RegisterFlagCompletionFunc("status", statusCompletion) + ListCmd.Flags().String("search", "", "filter issues by keyword") // TODO add way to sort by recent or the ones the user has participated on