completions: fix short option conflict in zsh completion

This commit is contained in:
Michael Cho 2024-09-26 20:23:08 -04:00
parent 7156fb7d3a
commit 910a5c3d3f
No known key found for this signature in database
GPG Key ID: 55E85E28A7CD1E85
2 changed files with 27 additions and 27 deletions

View File

@ -266,10 +266,10 @@ module Homebrew
sig { params(command: String, option: String).returns(String) } sig { params(command: String, option: String).returns(String) }
def self.generate_zsh_option_exclusions(command, option) 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 return "" unless conflicts.presence
"(#{conflicts.map { |conflict| "--#{conflict}" }.join(" ")})" "(#{conflicts.map { |conflict| "-#{"-" if conflict.size > 1}#{conflict}" }.join(" ")})"
end end
sig { params(commands: T::Array[String]).returns(String) } sig { params(commands: T::Array[String]).returns(String) }

View File

@ -961,7 +961,7 @@ _brew_fetch() {
'(--cask)--formula[Treat all named arguments as formulae]' \ '(--cask)--formula[Treat all named arguments as formulae]' \
'*::formula:__brew_formulae' \ '*::formula:__brew_formulae' \
- cask \ - 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' '*::cask:__brew_casks'
} }
@ -1287,22 +1287,22 @@ _brew_linkage() {
# brew list # brew list
_brew_list() { _brew_list() {
_arguments \ _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]' \ '--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]' \ '--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-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-on-request[List the formulae installed on request]' \
'(--cask --pinned)--multiple[Only show formulae with multiple versions installed]' \ '(--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 --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 --versions --pinned -l --full-name)--poured-from-bottle[List the formulae installed from a bottle]' \
'--quiet[Make some output more quiet]' \ '--quiet[Make some output more quiet]' \
'--verbose[Make some output more verbose]' \ '--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]' \ '(--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]' \ '(--versions --pinned)-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]' \ '(--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]' \
'-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)-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]' \ '(--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 \ - installed_formula \
'(--cask)--formula[List only formulae, or treat all named arguments as formulae]' \ '(--cask)--formula[List only formulae, or treat all named arguments as formulae]' \
'*::installed_formula:__brew_installed_formulae' \ '*::installed_formula:__brew_installed_formulae' \
@ -1354,13 +1354,13 @@ _brew_log() {
_arguments \ _arguments \
'--debug[Display any debugging information]' \ '--debug[Display any debugging information]' \
'--help[Show this message]' \ '--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]' \ '--oneline[Print only one line per commit]' \
'--patch[Also print patch from commit]' \ '--patch[Also print patch from commit]' \
'--quiet[Make some output more quiet]' \ '--quiet[Make some output more quiet]' \
'--stat[Also print diffstat from commit]' \ '--stat[Also print diffstat from commit]' \
'--verbose[Make some output more verbose]' \ '--verbose[Make some output more verbose]' \
'-1[Print only one commit]' \ '(--max-count)-1[Print only one commit]' \
- formula \ - formula \
'(--cask)--formula[Treat all named arguments as formulae]' \ '(--cask)--formula[Treat all named arguments as formulae]' \
'*::formula:__brew_formulae' \ '*::formula:__brew_formulae' \
@ -1372,22 +1372,22 @@ _brew_log() {
# brew ls # brew ls
_brew_ls() { _brew_ls() {
_arguments \ _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]' \ '--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]' \ '--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-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-on-request[List the formulae installed on request]' \
'(--cask --pinned)--multiple[Only show formulae with multiple versions installed]' \ '(--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 --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 --versions --pinned -l --full-name)--poured-from-bottle[List the formulae installed from a bottle]' \
'--quiet[Make some output more quiet]' \ '--quiet[Make some output more quiet]' \
'--verbose[Make some output more verbose]' \ '--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]' \ '(--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]' \ '(--versions --pinned)-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]' \ '(--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]' \
'-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)-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]' \ '(--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 \ - installed_formula \
'(--cask)--formula[List only formulae, or treat all named arguments as formulae]' \ '(--cask)--formula[List only formulae, or treat all named arguments as formulae]' \
'*::installed_formula:__brew_installed_formulae' \ '*::installed_formula:__brew_installed_formulae' \