feat(cli): shell completions — hidden completions subcommand + post-init hint (v3.2.19)#61
Merged
Conversation
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.
Summary
Last open item of the v3.3 batch (the other three shipped in v3.2.18 / #60). Adds shell completion support so the Homebrew formula can auto-install completions and npm/cargo users get a discovery path.
onebrain completions <SHELL>subcommand — emits a completion script to stdout viaclap_complete::generate()overCli::command().#[command(hide = true)]keeps it out of--helpbut still dispatchable (so the Homebrew formula'sgenerate_completions_from_executablecan call it). Supports all five shells clap_complete provides: bash · zsh · fish · powershell · elvish.onebrain init— detects the login shell from$SHELLand prints a copy-pasteableonebrain completions <detected>line (falls back to a<shell>placeholder + list when undetectable). Gated toexit_code == 0 && !yes && !structured_outputso machine/JSON output stays clean. Lives in the CLI layer, not the fs lib.Version: patch v3.2.19 (the command is hidden → no advertised surface → patch, not minor).
Out of scope (follow-up)
generate_completions_from_executable) — separate PR inhomebrew-onebrain, lands after v3.2.19 is released (the formula needs a released binary that carries the subcommand).Testing
tests/completions.rs): per-shell marker assertions (#compdef onebrain,_onebrain(),complete -c onebrain) — not snapshots (brittle across clap bumps) — unknown-shell rejection, andinit --yeshint absence.commands::completions): login-shell detection (incl. bare-name, case-insensitive, trailing-slash/whitespace edge cases) + hint builder.--helphidescompletionsandcompletions zshemits clean stdout (0 bytes stderr — banner is stderr-only, so brew-captured completion files won't be corrupted).Design / plan
01-projects/onebrain/cli/2026-05-29-shell-completions-design.md01-projects/onebrain/cli/2026-05-29-shell-completions-plan.md🤖 Generated with Claude Code