feat: Cask generate completions from executable#21671
feat: Cask generate completions from executable#21671tiluckdave wants to merge 5 commits intoHomebrew:mainfrom
Conversation
Since cask/staged.rb now has @api public methods, it needs to be included in the Style/Documentation check. Made-with: Cursor
46afe01 to
7fc0eac
Compare
Made-with: Cursor
| | ----------------------------------------- | ------------------------------------------------ | ----------- | | ||
| | `set_ownership(paths)` | `preflight`, `postflight`, `uninstall_preflight` | Set user and group ownership of `paths`. (Example: [docker-toolbox.rb](https://github.com/Homebrew/homebrew-cask/blob/aa461148bbb5119af26b82cccf5003e2b4e50d95/Casks/d/docker-toolbox.rb#L42)) | | ||
| | `set_permissions(paths, permissions_str)` | `preflight`, `postflight`, `uninstall_preflight` | Set permissions in `paths` to `permissions_str`. (Example: [ngrok.rb](https://github.com/Homebrew/homebrew-cask/blob/41d91ff669d85343175202adf568e2328486205f/Casks/n/ngrok.rb#L30)) | | ||
| | [`generate_completions_from_executable`](/rubydoc/Cask/Staged.html#generate_completions_from_executable-instance_method) | `postflight` | Generate shell completions by running the installed executable. | |
There was a problem hiding this comment.
I can't say for sure that generated completions is something we would want to support for Casks, but if we were to go ahead I think it would make sense for this to be a dsl that is use as an installation artifact rather than in a postflight block. Ideally it would automatically detect and store the generated completions so they could automatically be uninstalled without having to have a matching stanza in uninstall (like how other artifacts work).
There was a problem hiding this comment.
Yeh, I agree. We're trying to get rid of postflight blocks for Casks so this feels like a step in the wrong direction, sadly.
There was a problem hiding this comment.
Hm okay. Closing this one!
I will open a new PR for this
4459b13 to
c611306
Compare
brew lgtm(style, typechecking and tests) with your changes locally?AI is used to understand how completions work for formulae and to write tests and docs!
Added generate_completions_from_executable for Casks, enabling dynamic shell completion generation (bash, zsh, fish, pwsh) in postflight blocks—matching existing Formula functionality. Also added remove_generated_completions for cleanup on uninstall.
Verified by creating a mock CLI tool that generates completions for all 4 shells. Manually tested with bash and zsh.
brew doctorandbrew lgtmare clean.Fixes #21482