fix(cli): alias alert/channel single-record reads to the get/detail spellings - #127
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The verb for fetching a single record is spelled inconsistently across resources:
incidentanswers bothget <id>anddetail <id>.alertanswers onlyget <alert_id>—flashduty alert detail <id>fails withunknown command "detail".channelanswers only the path-derivedinfo <channel-id>—flashduty channel get <id>andflashduty 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 getgains aliasdetail, matchingincident's get/detail pair.channel infogains aliasesgetanddetail. The channel command tree is generated byinternal/cmd/cligen, so the aliases live in a newopAliasesmap in the generator — keyed by operationId, the same pattern as the existingpositionalOverride— and are emitted into the generated command. They survivego 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 asalert get(POST /alert/info).flashduty channel get <id>/flashduty channel detail <id>→ same request aschannel info(POST /channel/info).alert gt→ suggestsget).Verification
internal/cli/verb_aliases_test.go:alert detailandchannel get/detailare asserted to hit the same wire path and body as their canonical verbs (against the httptest stub);--helpthrough an alias renders the canonical command's help;alert show/channel showstill fail withunknown 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../bin/flashduty alert detail --helpprints the alert get help;./bin/flashduty channel get --helpandchannel detail --helpprint the channel info help;./bin/flashduty channel show 1001errorsunknown command "show" for "flashduty channel".Note:
go test -race -count=2 ./internal/cli/trips a pre-existing test-harness gap (resetFlagSetdoesn't reset int-slice flags, soTestCommandIncidentCreateSetsAssignTypesees accumulatedperson_idson the second in-process run). It reproduces identically onmainwithout this change and does not affect the defaultcount=1runs used bymake testand CI.