feat(min)!: split completions into print and install verbs - #1009
Conversation
📝 WalkthroughWalkthroughThe ChangesCompletion installation flow
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Comment |
f657cae to
4e876f9
Compare
4e876f9 to
fec83ff
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/reference/cli-min.md`:
- Around line 169-172: Declare the fenced code block language for the completion
commands by changing the fence around the min completions examples to use sh,
preserving the existing command text unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c69916a6-7cdb-4554-8527-c7a87a2b6ff4
📒 Files selected for processing (6)
crates/minimal/src/completions.rscrates/minimal/src/lib.rscrates/minimal/src/main.rsdocs/reference/cli-min.mdscripts/install.shscripts/install_test.sh
| ``` | ||
| min completions <SHELL> | ||
| min completions print <SHELL> | ||
| min completions install [<SHELL>...] | ||
| ``` |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Declare the command fence language.
This triggers markdownlint MD040.
Proposed fix
-```
+```sh
min completions print <SHELL>
min completions install [<SHELL>...]</details>
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
```suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.23.1)
[warning] 169-169: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/reference/cli-min.md` around lines 169 - 172, Declare the fenced code
block language for the completion commands by changing the fence around the min
completions examples to use sh, preserving the existing command text unchanged.
Source: Linters/SAST tools
Move the installer's completion bookkeeping — per-shell target path, atomic write, unwritable-dir tolerance, zsh compinit invalidation — out of scripts/install.sh and into the binary, so it is reachable by everyone rather than only by users who installed via curl | sh. The installer now delegates and records the paths install reports. install prints every path it wrote on stdout, one per line; that is the contract between the two halves, and the installer derives no paths of its own. BREAKING CHANGE: min completions <shell> is now min completions print <shell>. Refs: #1005 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The naming convention requires both spellings of a noun to show in --help; clap's `alias` is hidden, `visible_alias` is not. Refs: #1005 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
df8d664 to
2a28979
Compare
#1009 split `min completions <shell>` into `completions print` and `completions install`; the release job still called the flat form, so `Generate completions` exited 2 on run 30425725370 and the release never reached GCS or the GitHub Release. Switch the three `min` lines to `completions print <shell>`, and name their outputs after the `min` binary (`min`, `_min`, `min.fish`) rather than the crate: the shim `min` prints registers the command `min`, so a shell only ever autoloads it from a file of that name — the `minimal`/`_minimal` files shipped in `completions.tar.gz` since the binary rename (#737) were dead on arrival. `mip` and `minimald` keep the flat verb; only the `min` CLI changed. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Breaking change to the
mincommand surface. Part of the<noun> <verb>sweep started by #976.
Before / after
completionsalso acceptscompletion, per the singular/plural alias rule.Why
installexistsAll the bookkeeping around actually installing a completion file — the target
directory per shell, the atomic write, tolerating an unwritable directory,
invalidating a stale zsh
compinitdump — lived inscripts/install.sh. Thatmade it reachable only by people who installed via
curl | sh. It now lives inthe binary, and the installer delegates.
installwrites to:bash$XDG_DATA_HOME/bash-completion/completions/minzsh$XDG_DATA_HOME/zsh/completions/_minfish$XDG_CONFIG_HOME/fish/completions/min.fishWith no shell argument it installs all three.
printstill accepts every shellclap supports, including
elvish;installcovers only the three with aconventional per-user completion path.
The stdout contract
installprints every path it wrote to stdout, one per line.scripts/install.shrecords exactly those paths in its install record — it derives no paths of its
own, so
uninstallstays correct even if the binary's target paths change.Warnings (unwritable directory) and notices (dropped compinit dump) go to
stderr, which the installer relays in its own voice.
An unwritable completion directory is a warning, not a failure: the remaining
shells still install and the exit status is still 0. The binaries are already
correctly installed at that point; completions regenerate on the next run.
Verification
just test-installercargo build -p minimalThe harness gained a test that drives a mock
minwhich installs completionssomewhere the installer would never derive, asserting the installer records
that path and none of its own — the contract above, tested adversarially.
Because the harness drives a mock, the real implementation was also exercised
by hand against throwaway
HOMEs:min completions installwith no args → installed all three, printed allthree paths, clean stderr, exit 0
~/.config/fish/completionschmod'd 500 → bash and zsh installed andprinted, fish warned on stderr, exit 0, no fish file written, no raw
permission deniedleakmin completions print bash→ emits the_clap_complete_minshimFollow-up
mip completionsstill has the old single-verb shape. Same treatment applies;not done here to keep this reviewable.
Refs #1005
🤖 Generated with Claude Code
Note
Split
min completionsintoprintandinstallsubcommandsmin completions <shell>argument with two subcommands:print(writes the registration shim to stdout) andinstall(atomically installs completions into XDG autoload paths).installperforms best-effort installation across Bash, Zsh, and Fish, printing installed paths on stdout and warnings on stderr without failing on unwritable directories; it also drops the zsh compinit cache after install.min completions install <shell>, recording exactly the paths reported on stdout and relaying stderr warnings.min completions <shell>must switch tomin completions print <shell>;min completionis added as a visible alias.Macroscope summarized 2a28979.
Summary by CodeRabbit
New Features
min completions printto output shell completion scripts.min completions installfor Bash, Zsh, and Fish.Documentation
Bug Fixes