Skip to content

Commit e7d4dae

Browse files
authored
Merge pull request #44 from flashcatcloud/feat/ai-sre
release: feat/ai-sre → main (incident list --channel-id)
2 parents c32f4eb + 6c2d053 commit e7d4dae

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

internal/cli/incident.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ func newIncidentListCmd() *cobra.Command {
124124
cmd.Flags().StringVar(&severity, "severity", "", "Filter: Critical,Warning,Info")
125125
registerEnumFlag(cmd, "progress", "Triggered", "Processing", "Closed")
126126
registerEnumFlag(cmd, "severity", severityEnum...)
127-
cmd.Flags().Int64Var(&channelID, "channel", 0, "Filter by channel ID")
127+
// --channel-id matches the sibling channel commands (channel info
128+
// --channel-id, channel escalate-rule-list --channel-id).
129+
cmd.Flags().Int64Var(&channelID, "channel-id", 0, "Filter by channel ID")
128130
cmd.Flags().StringVar(&query, "query", "", "Free-text search across title/labels/content (also resolves a 24-char incident ID or 6-char incident num to a direct lookup)")
129131
cmd.Flags().StringVar(&nums, "nums", "", "Comma-separated short incident ids (num, the 6-char id shown in the UI) to filter by")
130132
cmd.Flags().StringVar(&since, "since", "24h", "Start time (duration, date, datetime, or unix timestamp; --since→--until window must be < 31 days)")

internal/cli/incident_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cli
22

33
import (
4+
"fmt"
45
"testing"
56
)
67

@@ -26,3 +27,23 @@ func TestCommandIncidentSimilarLimitReachesWire(t *testing.T) {
2627
t.Errorf("incident_id = %#v, want inc-1", stub.lastBody["incident_id"])
2728
}
2829
}
30+
31+
// TestCommandIncidentListChannelIDFlag verifies that `incident list` accepts
32+
// the canonical --channel-id flag (consistent with the sibling channel
33+
// commands, e.g. `channel info --channel-id`) and forwards it to /incident/list
34+
// as channel_ids. An agent that transferred --channel-id from those commands
35+
// previously hit "unknown flag: --channel-id" and wasted a turn.
36+
func TestCommandIncidentListChannelIDFlag(t *testing.T) {
37+
saveAndResetGlobals(t)
38+
stub := newGFStub(t)
39+
40+
if _, err := execCommand("incident", "list", "--channel-id", "123"); err != nil {
41+
t.Fatalf("execCommand --channel-id: %v", err)
42+
}
43+
if stub.lastPath != "/incident/list" {
44+
t.Fatalf("path = %q, want /incident/list", stub.lastPath)
45+
}
46+
if got, want := fmt.Sprint(stub.lastBody["channel_ids"]), "[123]"; got != want {
47+
t.Fatalf("channel_ids = %q, want %q", got, want)
48+
}
49+
}

0 commit comments

Comments
 (0)