Skip to content

fix(cli): make incident list --channel match sibling list verbs - #160

Merged
ysyneu merged 1 commit into
mainfrom
fix/incident-list-channel-flag
Aug 21, 2026
Merged

fix(cli): make incident list --channel match sibling list verbs#160
ysyneu merged 1 commit into
mainfrom
fix/incident-list-channel-flag

Conversation

@ysyneu

@ysyneu ysyneu commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Problem

incident list was the only list verb whose channel filter used
--channel-id <int64> (a single channel ID). Every other list verb —
alert list, alert-event list, change list — filters by channel via
--channel <comma-separated IDs>. A user or script that learned the
--channel convention from any of those commands and then tried
incident list --channel <id> got unknown flag: --channel.

The API this command calls already supports multiple channel IDs
(ListIncidentsRequest.ChannelIDs []int64), so this was a naming
inconsistency in the CLI, not a capability gap in the backend.

Fix

  • incident list now takes --channel <string>, comma-separated channel
    IDs, parsed with the same parseIntSlice helper alert list and
    change list already use, and forwarded as ChannelIDs.
  • --channel-id is kept working as a deprecated, hidden single-ID alias
    (cobra's MarkDeprecated, which also hides it from --help) so
    existing scripts that pass --channel-id keep working. --channel
    wins if both are passed.
  • internal/skilldoc/build.go's flag walk (used to generate the
    skills/flashduty command reference cards) did not skip hidden flags,
    so the generated card for incident list would have kept documenting
    the now-hidden --channel-id. Added a one-line filter to skip hidden
    flags, matching the existing hidden/deprecated skip that already
    applies one level up, to commands themselves. Regenerated
    skills/flashduty/reference/incident.md via make gen-cards.

Verification

$ go build ./...
$ go test ./...
ok  	github.com/flashcatcloud/flashduty-cli/cmd/flashduty
ok  	github.com/flashcatcloud/flashduty-cli/internal/cli
ok  	github.com/flashcatcloud/flashduty-cli/internal/cmd/cligen
ok  	github.com/flashcatcloud/flashduty-cli/internal/cmd/skilldoc
ok  	github.com/flashcatcloud/flashduty-cli/internal/config
ok  	github.com/flashcatcloud/flashduty-cli/internal/output
ok  	github.com/flashcatcloud/flashduty-cli/internal/skilldoc
ok  	github.com/flashcatcloud/flashduty-cli/internal/timeutil
ok  	github.com/flashcatcloud/flashduty-cli/internal/update

$ go run ./cmd/flashduty incident list --help 2>&1 | grep -- '--channel'
      --channel string    Comma-separated channel IDs

$ go run ./cmd/flashduty incident list --channel-id 1 --help
(exits 0, help renders; stderr: "Flag --channel-id has been deprecated, use --channel instead")

$ make gen-cards && git diff skills/flashduty/reference/incident.md
-- `--channel-id` int64
++ `--channel` string

$ make check-cards
skilldoc: cards OK

$ make fmt && git diff --stat
(no additional diff)

$ make lint
0 issues.

incident list was the only list verb that filtered by channel via
--channel-id (a single int64), while alert list, alert-event list, and
change list all use --channel (a comma-separated string parsed into
multiple channel IDs). The underlying API (ListIncidentsRequest.ChannelIDs
[]int64) already supports multiple channel IDs, so incident list's flag
was an unnecessary outlier rather than a capability gap.

Add --channel string to incident list, parsed with the same
parseIntSlice helper alert list and change list already use, and forward
it as ChannelIDs. Keep --channel-id working as a deprecated, hidden
single-ID alias via cobra's MarkDeprecated so existing scripts do not
break; --channel wins when both are set.

internal/skilldoc/build.go's command() walked every flag via
Flags().VisitAll without skipping hidden ones, so the generated skill
card for incident list would have kept showing the now-hidden
--channel-id. Filter out hidden flags there, matching the existing
hidden/deprecated skip one level up for commands themselves, then
regenerate skills/flashduty/reference/incident.md via 'make gen-cards'.

Verified:
- go build ./... and go test ./... pass
- 'incident list --help' shows --channel and no longer shows --channel-id
- 'incident list --channel-id 1 --help' still exits 0 and prints pflag's
  deprecation notice on stderr
- 'make check-cards' passes, confirming the skill card and CLI flag set
  are back in lockstep
@ysyneu
ysyneu merged commit a10587c into main Aug 21, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant