Merge polecat/Coma: add --pinned/--no-pinned list flags
This commit is contained in:
@@ -129,6 +129,10 @@ var listCmd = &cobra.Command{
|
|||||||
priorityMinStr, _ := cmd.Flags().GetString("priority-min")
|
priorityMinStr, _ := cmd.Flags().GetString("priority-min")
|
||||||
priorityMaxStr, _ := cmd.Flags().GetString("priority-max")
|
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
|
// Use global jsonOutput set by PersistentPreRun
|
||||||
|
|
||||||
// Normalize labels: trim, dedupe, remove empty
|
// Normalize labels: trim, dedupe, remove empty
|
||||||
@@ -265,6 +269,19 @@ var listCmd = &cobra.Command{
|
|||||||
filter.PriorityMax = &priorityMax
|
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)
|
// Check database freshness before reading (bd-2q6d, bd-c4rq)
|
||||||
// Skip check when using daemon (daemon auto-imports on staleness)
|
// Skip check when using daemon (daemon auto-imports on staleness)
|
||||||
ctx := rootCtx
|
ctx := rootCtx
|
||||||
@@ -340,6 +357,9 @@ var listCmd = &cobra.Command{
|
|||||||
listArgs.PriorityMin = filter.PriorityMin
|
listArgs.PriorityMin = filter.PriorityMin
|
||||||
listArgs.PriorityMax = filter.PriorityMax
|
listArgs.PriorityMax = filter.PriorityMax
|
||||||
|
|
||||||
|
// Pinned filtering (bd-p8e)
|
||||||
|
listArgs.Pinned = filter.Pinned
|
||||||
|
|
||||||
resp, err := daemonClient.List(listArgs)
|
resp, err := daemonClient.List(listArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
@@ -553,6 +573,10 @@ func init() {
|
|||||||
listCmd.Flags().String("priority-min", "", "Filter by minimum priority (inclusive, 0-4 or P0-P4)")
|
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)")
|
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
|
// Note: --json flag is defined as a persistent flag in main.go, not here
|
||||||
rootCmd.AddCommand(listCmd)
|
rootCmd.AddCommand(listCmd)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,6 +156,9 @@ type ListArgs struct {
|
|||||||
// Priority range
|
// Priority range
|
||||||
PriorityMin *int `json:"priority_min,omitempty"`
|
PriorityMin *int `json:"priority_min,omitempty"`
|
||||||
PriorityMax *int `json:"priority_max,omitempty"`
|
PriorityMax *int `json:"priority_max,omitempty"`
|
||||||
|
|
||||||
|
// Pinned filtering (bd-p8e)
|
||||||
|
Pinned *bool `json:"pinned,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountArgs represents arguments for the count operation
|
// CountArgs represents arguments for the count operation
|
||||||
|
|||||||
@@ -698,6 +698,9 @@ func (s *Server) handleList(req *Request) Response {
|
|||||||
filter.PriorityMin = listArgs.PriorityMin
|
filter.PriorityMin = listArgs.PriorityMin
|
||||||
filter.PriorityMax = listArgs.PriorityMax
|
filter.PriorityMax = listArgs.PriorityMax
|
||||||
|
|
||||||
|
// Pinned filtering (bd-p8e)
|
||||||
|
filter.Pinned = listArgs.Pinned
|
||||||
|
|
||||||
// Guard against excessive ID lists to avoid SQLite parameter limits
|
// Guard against excessive ID lists to avoid SQLite parameter limits
|
||||||
const maxIDs = 1000
|
const maxIDs = 1000
|
||||||
if len(filter.IDs) > maxIDs {
|
if len(filter.IDs) > maxIDs {
|
||||||
|
|||||||
Reference in New Issue
Block a user