Skip to content

fix(cli): alias alert/channel single-record reads to the get/detail spellings - #127

Merged
ysyneu merged 1 commit into
mainfrom
fix/get-detail-verb-aliases
Jul 30, 2026
Merged

fix(cli): alias alert/channel single-record reads to the get/detail spellings#127
ysyneu merged 1 commit into
mainfrom
fix/get-detail-verb-aliases

Conversation

@ysyneu

@ysyneu ysyneu commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Problem

The verb for fetching a single record is spelled inconsistently across resources:

  • incident answers both get <id> and detail <id>.
  • alert answers only get <alert_id>flashduty alert detail <id> fails with unknown command "detail".
  • channel answers only the path-derived info <channel-id>flashduty channel get <id> and flashduty channel detail <id> both fail.

These slips are mechanically unambiguous — there is exactly one single-record read per resource — but they cost the caller an error round-trip (the did-you-mean hints still require a retry).

Change

Aliases make the slip free; the canonical verbs are unchanged.

  • alert get gains alias detail, matching incident's get/detail pair.
  • channel info gains aliases get and detail. The channel command tree is generated by internal/cmd/cligen, so the aliases live in a new opAliases map in the generator — keyed by operationId, the same pattern as the existing positionalOverride — and are emitted into the generated command. They survive go run ./internal/cmd/cligen (verified: re-running the generator produces no drift).

Nothing else is aliased or renamed; help text is untouched beyond what cobra renders for aliases.

Behavior

  • flashduty alert detail <id> → same request as alert get (POST /alert/info).
  • flashduty channel get <id> / flashduty channel detail <id> → same request as channel info (POST /channel/info).
  • Truly unknown verbs keep the existing loud failure, including did-you-mean suggestions for near misses (e.g. alert gt → suggests get).

Verification

  • New tests in internal/cli/verb_aliases_test.go: alert detail and channel get/detail are asserted to hit the same wire path and body as their canonical verbs (against the httptest stub); --help through an alias renders the canonical command's help; alert show / channel show still fail with unknown command, and a near-miss typo still gets a suggestion block.
  • make check (gofmt/gci, golangci-lint, go test -race ./..., build) — green.
  • make check-cards (skill command-cards vs command tree) — green.
  • Smoke: ./bin/flashduty alert detail --help prints the alert get help; ./bin/flashduty channel get --help and channel detail --help print the channel info help; ./bin/flashduty channel show 1001 errors unknown command "show" for "flashduty channel".

Note: go test -race -count=2 ./internal/cli/ trips a pre-existing test-harness gap (resetFlagSet doesn't reset int-slice flags, so TestCommandIncidentCreateSetsAssignType sees accumulated person_ids on the second in-process run). It reproduces identically on main without this change and does not affect the default count=1 runs used by make test and CI.

…pellings

The single-record read verb is inconsistent across resources: incident
answers both "get" and "detail", alert answered only "get", and channel
answered only the path-derived "info". The analogy-driven slips
(`alert detail <id>`, `channel get <id>`, `channel detail <id>`) failed
with "unknown command" even though the intended operation is unambiguous.

- alert get gains the "detail" alias, matching incident's get/detail pair.
- channel info gains "get" and "detail" aliases. The channel command tree
  is generated by cligen, so the aliases live in a new opAliases map in
  the generator (keyed by operationId, the same pattern as
  positionalOverride) and are emitted into the generated command, so they
  survive regeneration.

Genuinely unknown verbs keep the existing loud failure with did-you-mean
suggestions. Tests cover alias resolution to the same wire request, --help
through an alias, and the unchanged unknown-verb behavior.
@ysyneu
ysyneu merged commit 35ba373 into main Jul 30, 2026
12 checks passed
@ysyneu
ysyneu deleted the fix/get-detail-verb-aliases branch July 30, 2026 12:23
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