Add label and title filtering to bd list (closes #45, bd-269)

- Add --label/-l flag to filter issues by labels (AND logic)
- Add --title flag to filter issues by title substring
- Add TitleSearch field to IssueFilter type
- Implement label and title filtering in SearchIssues
- Perfect for worktree-specific issue management

Examples:
  bd list --label worktree,feature-x
  bd list --title "authentication"
  bd list --label worktree --title "bug"
This commit is contained in:
Steve Yegge
2025-10-15 23:51:57 -07:00
parent 30c774a976
commit e2c42c35c4
4 changed files with 32 additions and 6 deletions

View File

@@ -1151,6 +1151,12 @@ func (s *SQLiteStorage) SearchIssues(ctx context.Context, query string, filter t
args = append(args, pattern, pattern, pattern)
}
if filter.TitleSearch != "" {
whereClauses = append(whereClauses, "title LIKE ?")
pattern := "%" + filter.TitleSearch + "%"
args = append(args, pattern)
}
if filter.Status != nil {
whereClauses = append(whereClauses, "status = ?")
args = append(args, *filter.Status)
@@ -1171,6 +1177,14 @@ func (s *SQLiteStorage) SearchIssues(ctx context.Context, query string, filter t
args = append(args, *filter.Assignee)
}
// Label filtering: issue must have ALL specified labels
if len(filter.Labels) > 0 {
for _, label := range filter.Labels {
whereClauses = append(whereClauses, "id IN (SELECT issue_id FROM labels WHERE label = ?)")
args = append(args, label)
}
}
whereSQL := ""
if len(whereClauses) > 0 {
whereSQL = "WHERE " + strings.Join(whereClauses, " AND ")