Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completions: fix short option conflict in zsh completion #18432

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Library/Homebrew/completions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ def self.generate_zsh_subcommand_completion(command)

sig { params(command: String, option: String).returns(String) }
def self.generate_zsh_option_exclusions(command, option)
conflicts = Commands.option_conflicts(command, option.gsub(/^--/, ""))
conflicts = Commands.option_conflicts(command, option.gsub(/^--?/, ""))
return "" unless conflicts.presence

"(#{conflicts.map { |conflict| "--#{conflict}" }.join(" ")})"
"(#{conflicts.map { |conflict| "-#{"-" if conflict.size > 1}#{conflict}" }.join(" ")})"
end

sig { params(commands: T::Array[String]).returns(String) }
Expand Down
50 changes: 25 additions & 25 deletions completions/zsh/_brew
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ _brew_fetch() {
'(--cask)--formula[Treat all named arguments as formulae]' \
'*::formula:__brew_formulae' \
- cask \
'(--HEAD --deps --s --build-bottle --force-bottle --bottle-tag --formula)--cask[Treat all named arguments as casks]' \
'(--HEAD --deps -s --build-bottle --force-bottle --bottle-tag --formula)--cask[Treat all named arguments as casks]' \
'*::cask:__brew_casks'
}

Expand Down Expand Up @@ -1287,22 +1287,22 @@ _brew_linkage() {
# brew list
_brew_list() {
_arguments \
'(--cask --versions --pinned --l --full-name)--built-from-source[List the formulae compiled from source]' \
'(--cask --versions --pinned -l --full-name)--built-from-source[List the formulae compiled from source]' \
'--debug[Display any debugging information]' \
'(--versions --pinned --installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source --l --r --t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \
'(--versions --pinned --installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source -l -r -t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \
'--help[Show this message]' \
'(--cask --versions --pinned --l --full-name)--installed-as-dependency[List the formulae installed as dependencies]' \
'(--cask --versions --pinned --l --full-name)--installed-on-request[List the formulae installed on request]' \
'(--cask --versions --pinned -l --full-name)--installed-as-dependency[List the formulae installed as dependencies]' \
'(--cask --versions --pinned -l --full-name)--installed-on-request[List the formulae installed on request]' \
'(--cask --pinned)--multiple[Only show formulae with multiple versions installed]' \
'(--cask --multiple --installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source --1 --l --r --t --full-name)--pinned[List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`]' \
'(--cask --versions --pinned --l --full-name)--poured-from-bottle[List the formulae installed from a bottle]' \
'(--cask --multiple --installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source -1 -l -r -t --full-name)--pinned[List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`]' \
'(--cask --versions --pinned -l --full-name)--poured-from-bottle[List the formulae installed from a bottle]' \
'--quiet[Make some output more quiet]' \
'--verbose[Make some output more verbose]' \
'(--installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source --1 --l --r --t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \
'-1[Force output to be one entry per line. This is the default when output is not to a terminal]' \
'-l[List formulae and/or casks in long format. Has no effect when a formula or cask name is passed as an argument]' \
'-r[Reverse the order of the formulae and/or casks sort to list the oldest entries first. Has no effect when a formula or cask name is passed as an argument]' \
'-t[Sort formulae and/or casks by time modified, listing most recently modified first. Has no effect when a formula or cask name is passed as an argument]' \
'(--installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source -1 -l -r -t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \
'(--versions --pinned)-1[Force output to be one entry per line. This is the default when output is not to a terminal]' \
'(--installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source --versions --pinned --full-name)-l[List formulae and/or casks in long format. Has no effect when a formula or cask name is passed as an argument]' \
'(--versions --pinned --full-name)-r[Reverse the order of the formulae and/or casks sort to list the oldest entries first. Has no effect when a formula or cask name is passed as an argument]' \
'(--versions --pinned --full-name)-t[Sort formulae and/or casks by time modified, listing most recently modified first. Has no effect when a formula or cask name is passed as an argument]' \
- installed_formula \
'(--cask)--formula[List only formulae, or treat all named arguments as formulae]' \
'*::installed_formula:__brew_installed_formulae' \
Expand Down Expand Up @@ -1354,13 +1354,13 @@ _brew_log() {
_arguments \
'--debug[Display any debugging information]' \
'--help[Show this message]' \
'(--1)--max-count[Print only a specified number of commits]' \
'(-1)--max-count[Print only a specified number of commits]' \
'--oneline[Print only one line per commit]' \
'--patch[Also print patch from commit]' \
'--quiet[Make some output more quiet]' \
'--stat[Also print diffstat from commit]' \
'--verbose[Make some output more verbose]' \
'-1[Print only one commit]' \
'(--max-count)-1[Print only one commit]' \
- formula \
'(--cask)--formula[Treat all named arguments as formulae]' \
'*::formula:__brew_formulae' \
Expand All @@ -1372,22 +1372,22 @@ _brew_log() {
# brew ls
_brew_ls() {
_arguments \
'(--cask --versions --pinned --l --full-name)--built-from-source[List the formulae compiled from source]' \
'(--cask --versions --pinned -l --full-name)--built-from-source[List the formulae compiled from source]' \
'--debug[Display any debugging information]' \
'(--versions --pinned --installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source --l --r --t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \
'(--versions --pinned --installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source -l -r -t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \
'--help[Show this message]' \
'(--cask --versions --pinned --l --full-name)--installed-as-dependency[List the formulae installed as dependencies]' \
'(--cask --versions --pinned --l --full-name)--installed-on-request[List the formulae installed on request]' \
'(--cask --versions --pinned -l --full-name)--installed-as-dependency[List the formulae installed as dependencies]' \
'(--cask --versions --pinned -l --full-name)--installed-on-request[List the formulae installed on request]' \
'(--cask --pinned)--multiple[Only show formulae with multiple versions installed]' \
'(--cask --multiple --installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source --1 --l --r --t --full-name)--pinned[List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`]' \
'(--cask --versions --pinned --l --full-name)--poured-from-bottle[List the formulae installed from a bottle]' \
'(--cask --multiple --installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source -1 -l -r -t --full-name)--pinned[List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`]' \
'(--cask --versions --pinned -l --full-name)--poured-from-bottle[List the formulae installed from a bottle]' \
'--quiet[Make some output more quiet]' \
'--verbose[Make some output more verbose]' \
'(--installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source --1 --l --r --t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \
'-1[Force output to be one entry per line. This is the default when output is not to a terminal]' \
'-l[List formulae and/or casks in long format. Has no effect when a formula or cask name is passed as an argument]' \
'-r[Reverse the order of the formulae and/or casks sort to list the oldest entries first. Has no effect when a formula or cask name is passed as an argument]' \
'-t[Sort formulae and/or casks by time modified, listing most recently modified first. Has no effect when a formula or cask name is passed as an argument]' \
'(--installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source -1 -l -r -t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \
'(--versions --pinned)-1[Force output to be one entry per line. This is the default when output is not to a terminal]' \
'(--installed-on-request --installed-as-dependency --poured-from-bottle --built-from-source --versions --pinned --full-name)-l[List formulae and/or casks in long format. Has no effect when a formula or cask name is passed as an argument]' \
'(--versions --pinned --full-name)-r[Reverse the order of the formulae and/or casks sort to list the oldest entries first. Has no effect when a formula or cask name is passed as an argument]' \
'(--versions --pinned --full-name)-t[Sort formulae and/or casks by time modified, listing most recently modified first. Has no effect when a formula or cask name is passed as an argument]' \
- installed_formula \
'(--cask)--formula[List only formulae, or treat all named arguments as formulae]' \
'*::installed_formula:__brew_installed_formulae' \
Expand Down
Loading