Merge polecat/Coma: add --pinned/--no-pinned list flags

This commit is contained in:
Steve Yegge
2025-12-19 01:28:45 -08:00
3 changed files with 32 additions and 2 deletions

View File

@@ -128,7 +128,11 @@ var listCmd = &cobra.Command{
// Priority range flags
priorityMinStr, _ := cmd.Flags().GetString("priority-min")
priorityMaxStr, _ := cmd.Flags().GetString("priority-max")
// Pinned filtering flags (bd-p8e)
pinnedFlag, _ := cmd.Flags().GetBool("pinned")
noPinnedFlag, _ := cmd.Flags().GetBool("no-pinned")
// Use global jsonOutput set by PersistentPreRun
// Normalize labels: trim, dedupe, remove empty
@@ -265,6 +269,19 @@ var listCmd = &cobra.Command{
filter.PriorityMax = &priorityMax
}
// Pinned filtering (bd-p8e): --pinned and --no-pinned are mutually exclusive
if pinnedFlag && noPinnedFlag {
fmt.Fprintf(os.Stderr, "Error: --pinned and --no-pinned are mutually exclusive\n")
os.Exit(1)
}
if pinnedFlag {
pinned := true
filter.Pinned = &pinned
} else if noPinnedFlag {
pinned := false
filter.Pinned = &pinned
}
// Check database freshness before reading (bd-2q6d, bd-c4rq)
// Skip check when using daemon (daemon auto-imports on staleness)
ctx := rootCtx
@@ -340,6 +357,9 @@ var listCmd = &cobra.Command{
listArgs.PriorityMin = filter.PriorityMin
listArgs.PriorityMax = filter.PriorityMax
// Pinned filtering (bd-p8e)
listArgs.Pinned = filter.Pinned
resp, err := daemonClient.List(listArgs)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
@@ -552,7 +572,11 @@ func init() {
// Priority ranges
listCmd.Flags().String("priority-min", "", "Filter by minimum priority (inclusive, 0-4 or P0-P4)")
listCmd.Flags().String("priority-max", "", "Filter by maximum priority (inclusive, 0-4 or P0-P4)")
// Pinned filtering (bd-p8e)
listCmd.Flags().Bool("pinned", false, "Show only pinned issues")
listCmd.Flags().Bool("no-pinned", false, "Exclude pinned issues")
// Note: --json flag is defined as a persistent flag in main.go, not here
rootCmd.AddCommand(listCmd)
}

View File

@@ -156,6 +156,9 @@ type ListArgs struct {
// Priority range
PriorityMin *int `json:"priority_min,omitempty"`
PriorityMax *int `json:"priority_max,omitempty"`
// Pinned filtering (bd-p8e)
Pinned *bool `json:"pinned,omitempty"`
}
// CountArgs represents arguments for the count operation

View File

@@ -698,6 +698,9 @@ func (s *Server) handleList(req *Request) Response {
filter.PriorityMin = listArgs.PriorityMin
filter.PriorityMax = listArgs.PriorityMax
// Pinned filtering (bd-p8e)
filter.Pinned = listArgs.Pinned
// Guard against excessive ID lists to avoid SQLite parameter limits
const maxIDs = 1000
if len(filter.IDs) > maxIDs {