feat(cli): shell tab-completion — enum flag values + install.sh auto-setup#27
Merged
Conversation
…setup Cobra already ships a `completion` subcommand, but (a) flag values never tab-completed and (b) the generated script was never installed, so users saw nothing on Tab. - Add internal/cli/completion.go: registerEnumFlag helper + shared severityEnum; wire it onto every closed-set flag (--output-format, incident --severity/--progress, alert/alert-event --severity, postmortem --status, monit-query --ds-type, template --type, statuspage --type). - install.sh: best-effort, non-intrusive auto-install of completion for the user's $SHELL (fish/bash user dirs; zsh only into a writable site-functions dir, else print copy-pasteable setup steps). Never edits ~/.zshrc. Handles a renamed binary via a `|`-delimited sed rewrite of the Cobra-baked root name. - Document --output-format/toon in README.md and skills/flashduty-shared/SKILL.md (previously only table/JSON were documented). Verified: go build/vet/test green, gofmt clean, sh -n + shellcheck clean, __complete returns the enum values for every wired flag, and install.sh writes correct per-shell scripts (default + renamed).
ysyneu
added a commit
that referenced
this pull request
Jun 2, 2026
Reconcile the full-OpenAPI-coverage feature with main's #26 (incident 6-char short-id resolution in detail/get + list --nums) and #27 (shell tab-completion + install.sh auto-setup). incident.go conflicts resolved to main's design: - list: keep --nums (#26) plus the eval's "--since→--until window < 31d" help text. - get: adopt #26's resolveIncidentArg→List-by-incident_ids body; the full-coverage branch's /incident/info get is superseded by #26's new `detail` command (which carries the no-window Info path). All 7 incident short-id tests pass. postmortem.go / status_page.go (deleted by the coverage branch in favor of generated commands) kept deleted; #27's registerEnumFlag additions to them drop with the files — generated post-mortem/status-page commands cover those ops. completion.go + install.sh + the curated commands' registerEnumFlag calls retained.
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.
What
Adds real shell tab-completion to the
flashdutyCLI, and makes installation set it up automatically.Cobra already ships a hidden
completionsubcommand, but two gaps meant users saw nothing useful on<Tab>:--output-format <Tab>gave nothing).Changes
internal/cli/completion.gowith a sharedregisterEnumFlaghelper + single-sourceseverityEnum, wired onto every closed-set flag:--output-format→table|json|toon--severity(list/create/update) +--progress--severity--status→drafting|published--ds-type→prometheus|victorialogs|loki|mysql--type→custom|sprig|all--type→incident|maintenanceinstall.shauto-install — best-effort, non-intrusive:$SHELL~/.config/fish/completions/, bash →~/.local/share/bash-completion/completions/(auto-loaded user dirs)site-functionsdir (e.g. Homebrew); otherwise prints copy-pasteable setup steps. Never edits~/.zshrc.setup_completion || true)INSTALLED_NAME) by rewriting Cobra's baked root name with a|-delimitedsed--output-format/tooninREADME.mdandskills/flashduty-shared/SKILL.md(previously onlytable/JSON were listed).Why non-intrusive for zsh
zsh has no guaranteed writable
fpathdir, so the only ways to make it "just work" everywhere are writing to a system dir (sudo) or editing~/.zshrc(intrusive, runs on everycurl | sh). We deliberately do neither — we install where the shell already auto-loads, and otherwise hand the user exact instructions. This matches thegh/kubectlnorm.Verification
go build/go vet/go test ./...— greengofmtclean on all touched filessh -n install.sh+shellcheck -s sh install.sh— cleanflashduty __complete … --<flag> ""returns the enum values (withNoFileComp) for every wired flaginstall.shwrites correct per-shell scripts for both the default name and a renamed (fduty) install; zsh fallback prints the right manual recipeNote
This is release-gated: the flag completion reaches users only after a rebuild+release, and the
install.shchange only after CI mirrors it to the CDN.