cask: add generate_completions_from_executable DSL artifact#21781
cask: add generate_completions_from_executable DSL artifact#21781MikeMcQuaid merged 6 commits intoHomebrew:mainfrom
Conversation
Adds a new `generate_completions_from_executable` stanza for Casks that runs an executable at install time to generate shell completion scripts, mirroring the existing Formula DSL method. The new `GeneratedCompletion` artifact class supports the same shell_parameter_format options as Formula (arg, clap, click, cobra, flag, none, typer, and custom prefix strings). Fixes Homebrew#21482. This contribution was developed with AI assistance (Claude Code + Codex).
SMillerDev
left a comment
There was a problem hiding this comment.
Thanks for working on this! A few comments to make it easier to maintain.
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Thanks! Looks good so far. Agreed with @SMillerDev that this should be sharing a lot more code with the similar formula implementation.
Move completion_shell_parameter and default_completion_shells into a shared Utils::ShellCompletion module used by both Formula and Cask::Artifact::GeneratedCompletion, eliminating the duplication.
|
Extracted
Typecheck, style, and tests all pass locally. |
The cask installer's install_phase and uninstall_phase methods use T.cast with an explicit union of artifact types. GeneratedCompletion was missing, causing a runtime T.cast error during cask installation.
|
Also fixed a bug in |
Move the shared popen_read invocation pattern from both Formula#generate_completions_from_executable and Cask::Artifact::GeneratedCompletion#install_phase into a single Utils::ShellCompletion.generate_completion_output method. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n artifacts Replace inline path computation in completion_script_path with calls to BashCompletion, ZshCompletion, and FishCompletion resolve_target, reusing the path logic already defined in the cask artifact hierarchy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Looks good to me so far! Would be good to have some utils/shell_completion specs too.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Added |
|
Thanks @mvanhorn! |
|
Thanks for the reviews and merge, @MikeMcQuaid and @SMillerDev! The back-and-forth on extracting |
|
This is amazing! Thanks, everyone! PS: do we need to update this? https://docs.brew.sh/Cask-Cookbook |
|
Yeah, an adjustment to the docs would be nice. @mvanhorn are you up for that? I don't want to steal your thunder for that one. |
Implements the generate_completions_from_executable DSL stanza for Homebrew Casks, mirroring the support added to Homebrew in Homebrew/brew#21781 (merged 2026-03-22). Config: generate_completions_from_executable: executable: "bin/myapp" args: ["completions"] base_name: "myapp" shell_parameter_format: cobra # arg|clap|click|cobra|flag|none|typer or custom string shells: [bash, zsh, fish, pwsh] Generated Ruby output: generate_completions_from_executable "bin/myapp", "completions", base_name: "myapp", shell_parameter_format: :cobra, shells: [:bash, :zsh, :fish, :pwsh] Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implements the generate_completions_from_executable DSL stanza for Homebrew Casks, mirroring the support added to Homebrew in Homebrew/brew#21781 (merged 2026-03-22). Config: generate_completions_from_executable: executable: "bin/myapp" # optional, defaults to first binary args: ["completions"] base_name: "myapp" shell_parameter_format: cobra # arg|clap|click|cobra|flag|none|typer or custom string shells: [bash, zsh, fish, pwsh] Generated Ruby output: generate_completions_from_executable "bin/myapp", "completions", base_name: "myapp", shell_parameter_format: :cobra, shells: [:bash, :zsh, :fish, :pwsh] Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implements the generate_completions_from_executable DSL stanza for Homebrew Casks, mirroring the support added to Homebrew in Homebrew/brew#21781 (merged 2026-03-22). Config: generate_completions_from_executable: executable: "bin/myapp" # optional, defaults to first binary args: ["completions"] base_name: "myapp" shell_parameter_format: cobra # arg|clap|click|cobra|flag|none|typer or custom string shells: [bash, zsh, fish, pwsh] Generated Ruby output: generate_completions_from_executable "bin/myapp", "completions", base_name: "myapp", shell_parameter_format: :cobra, shells: [:bash, :zsh, :fish, :pwsh] Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…6485) Implements the generate_completions_from_executable DSL stanza for Homebrew Casks, mirroring the support added to Homebrew in Homebrew/brew#21781 (merged 2026-03-22). Config: ```yaml generate_completions_from_executable: executable: "bin/myapp" # optional, defaults to first binary args: ["completions"] base_name: "myapp" shell_parameter_format: cobra # arg|clap|click|cobra|flag|none|typer or custom string shells: [bash, zsh, fish, pwsh] ``` Generated Ruby output: ```ruby generate_completions_from_executable "bin/myapp", "completions", base_name: "myapp", shell_parameter_format: :cobra, shells: [:bash, :zsh, :fish, :pwsh] ``` --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
brew lgtm(style, typechecking and tests) with your changes locally?This contribution was developed with AI assistance (Claude Code + Codex).
Implements a
generate_completions_from_executableDSL stanza for Casks as an artifact, per the direction discussed in #21482.Casks already support
bash_completion,zsh_completion, andfish_completionstanzas for symlinking pre-existing completion files. This PR adds the ability to run an executable at install time to generate completion scripts, matching the existing Formula DSL method.This is the artifact/DSL approach that @SMillerDev requested - not the postflight approach from #21671.
Changes
Cask::Artifact::GeneratedCompletionclass that:install_phaseto generate completionsuninstall_phaseshell_parameter_formatoptions as Formula (:arg,:clap,:click,:cobra,:flag,:none,:typer, and custom prefix strings)Usage
Fixes #21482.