Skip to content

feat: Cask generate completions from executable#21671

Closed
tiluckdave wants to merge 5 commits intoHomebrew:mainfrom
tiluckdave:feat/cask-generate-completions-from-executable
Closed

feat: Cask generate completions from executable#21671
tiluckdave wants to merge 5 commits intoHomebrew:mainfrom
tiluckdave:feat/cask-generate-completions-from-executable

Conversation

@tiluckdave
Copy link
Contributor

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR.

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 doctor and brew lgtm are clean.

Fixes #21482

Copilot AI review requested due to automatic review settings March 5, 2026 18:49
@tiluckdave tiluckdave changed the title Feat/cask generate completions from executable feat: Cask generate completions from executable Mar 5, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Since cask/staged.rb now has @api public methods, it needs to be
included in the Style/Documentation check.

Made-with: Cursor
@tiluckdave tiluckdave force-pushed the feat/cask-generate-completions-from-executable branch from 46afe01 to 7fc0eac Compare March 5, 2026 19:09
Made-with: Cursor
@tiluckdave tiluckdave requested a review from Copilot March 5, 2026 19:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

| ----------------------------------------- | ------------------------------------------------ | ----------- |
| `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. |
Copy link
Member

@bevanjkay bevanjkay Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@tiluckdave tiluckdave Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm okay. Closing this one!
I will open a new PR for this

@tiluckdave tiluckdave force-pushed the feat/cask-generate-completions-from-executable branch 2 times, most recently from 4459b13 to c611306 Compare March 9, 2026 16:34
@tiluckdave tiluckdave closed this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Casks cannot generate shell completions like formulae

4 participants