Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/cli/incident.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ func newIncidentListCmd() *cobra.Command {
cmd.Flags().StringVar(&severity, "severity", "", "Filter: Critical,Warning,Info")
registerEnumFlag(cmd, "progress", "Triggered", "Processing", "Closed")
registerEnumFlag(cmd, "severity", severityEnum...)
cmd.Flags().Int64Var(&channelID, "channel", 0, "Filter by channel ID")
// --channel-id matches the sibling channel commands (channel info
// --channel-id, channel escalate-rule-list --channel-id).
cmd.Flags().Int64Var(&channelID, "channel-id", 0, "Filter by channel ID")
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)")
cmd.Flags().StringVar(&nums, "nums", "", "Comma-separated short incident ids (num, the 6-char id shown in the UI) to filter by")
cmd.Flags().StringVar(&since, "since", "24h", "Start time (duration, date, datetime, or unix timestamp; --since→--until window must be < 31 days)")
Expand Down
21 changes: 21 additions & 0 deletions internal/cli/incident_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"fmt"
"testing"
)

Expand All @@ -26,3 +27,23 @@ func TestCommandIncidentSimilarLimitReachesWire(t *testing.T) {
t.Errorf("incident_id = %#v, want inc-1", stub.lastBody["incident_id"])
}
}

// TestCommandIncidentListChannelIDFlag verifies that `incident list` accepts
// the canonical --channel-id flag (consistent with the sibling channel
// commands, e.g. `channel info --channel-id`) and forwards it to /incident/list
// as channel_ids. An agent that transferred --channel-id from those commands
// previously hit "unknown flag: --channel-id" and wasted a turn.
func TestCommandIncidentListChannelIDFlag(t *testing.T) {
saveAndResetGlobals(t)
stub := newGFStub(t)

if _, err := execCommand("incident", "list", "--channel-id", "123"); err != nil {
t.Fatalf("execCommand --channel-id: %v", err)
}
if stub.lastPath != "/incident/list" {
t.Fatalf("path = %q, want /incident/list", stub.lastPath)
}
if got, want := fmt.Sprint(stub.lastBody["channel_ids"]), "[123]"; got != want {
t.Fatalf("channel_ids = %q, want %q", got, want)
}
}