mirror of
https://github.com/Homebrew/brew.git
synced 2024-11-25 16:33:34 +08:00
Remove fish command completions for excluded commands
This removes fish command completions (but keeps argument completions) for commands in the `COMPLETIONS_EXCLUSION_LIST` list. It also removes unnecessary exclusions of `*instal` aliases in command suggestions in bash and fish completions, since those were removed from `internal_commands_list.txt` in Homebrew#10229. This makes `COMPLETIONS_EXCLUSION_LIST` the single source of truth for commands to exclude from completions.
This commit is contained in:
parent
0b25b5ccbb
commit
c5253b23c2
@ -304,7 +304,11 @@ module Homebrew
|
||||
return unless command_gets_completions? command
|
||||
|
||||
command_description = format_description Commands.command_description(command, short: true), fish: true
|
||||
lines = ["__fish_brew_complete_cmd '#{command}' '#{command_description}'"]
|
||||
lines = if COMPLETIONS_EXCLUSION_LIST.include?(command)
|
||||
[]
|
||||
else
|
||||
["__fish_brew_complete_cmd '#{command}' '#{command_description}'"]
|
||||
end
|
||||
|
||||
options = command_options(command).sort.filter_map do |opt, desc|
|
||||
arg_line = "__fish_brew_complete_arg '#{command}' -l #{opt.sub(/^-+/, "")}"
|
||||
|
@ -108,7 +108,6 @@ __brew_complete_tapped() {
|
||||
|
||||
__brew_complete_commands() {
|
||||
# Auto-complete Homebrew commands
|
||||
# Do NOT auto-complete "*instal" aliases for "*install" commands
|
||||
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local cmds
|
||||
@ -118,10 +117,10 @@ __brew_complete_commands() {
|
||||
cmds=${__HOMEBREW_COMMANDS}
|
||||
elif [[ -n ${HOMEBREW_CACHE:-} && -f ${HOMEBREW_CACHE}/all_commands_list.txt ]]
|
||||
then
|
||||
cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt" \grep -v instal$)"
|
||||
cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt")"
|
||||
elif [[ -n ${HOMEBREW_REPOSITORY:-} && -f ${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt ]]
|
||||
then
|
||||
cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt" \grep -v instal$)"
|
||||
cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt")"
|
||||
fi
|
||||
while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${cmds}" -- "${cur}")
|
||||
export __HOMEBREW_COMMANDS=${cmds}
|
||||
|
@ -147,9 +147,9 @@ end
|
||||
|
||||
function __fish_brew_suggest_commands -d "Lists all commands names, including aliases"
|
||||
if test -f (brew --cache)/all_commands_list.txt
|
||||
cat (brew --cache)/all_commands_list.txt | \grep -v instal\$
|
||||
cat (brew --cache)/all_commands_list.txt
|
||||
else
|
||||
cat (brew --repo)/completions/internal_commands_list.txt | \grep -v instal\$
|
||||
cat (brew --repo)/completions/internal_commands_list.txt
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -95,7 +95,6 @@ __brew_complete_tapped() {
|
||||
|
||||
__brew_complete_commands() {
|
||||
# Auto-complete Homebrew commands
|
||||
# Do NOT auto-complete "*instal" aliases for "*install" commands
|
||||
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local cmds
|
||||
@ -105,10 +104,10 @@ __brew_complete_commands() {
|
||||
cmds=${__HOMEBREW_COMMANDS}
|
||||
elif [[ -n ${HOMEBREW_CACHE:-} && -f ${HOMEBREW_CACHE}/all_commands_list.txt ]]
|
||||
then
|
||||
cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt" \grep -v instal$)"
|
||||
cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt")"
|
||||
elif [[ -n ${HOMEBREW_REPOSITORY:-} && -f ${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt ]]
|
||||
then
|
||||
cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt" \grep -v instal$)"
|
||||
cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt")"
|
||||
fi
|
||||
while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${cmds}" -- "${cur}")
|
||||
export __HOMEBREW_COMMANDS=${cmds}
|
||||
|
@ -134,9 +134,9 @@ end
|
||||
|
||||
function __fish_brew_suggest_commands -d "Lists all commands names, including aliases"
|
||||
if test -f (brew --cache)/all_commands_list.txt
|
||||
cat (brew --cache)/all_commands_list.txt | \grep -v instal\$
|
||||
cat (brew --cache)/all_commands_list.txt
|
||||
else
|
||||
cat (brew --repo)/completions/internal_commands_list.txt | \grep -v instal\$
|
||||
cat (brew --repo)/completions/internal_commands_list.txt
|
||||
end
|
||||
end
|
||||
|
||||
@ -867,7 +867,6 @@ __fish_brew_complete_arg 'info; and not __fish_seen_argument -l cask -l casks' -
|
||||
__fish_brew_complete_arg 'info; and not __fish_seen_argument -l formula -l formulae' -a '(__fish_brew_suggest_casks_all)'
|
||||
|
||||
|
||||
__fish_brew_complete_cmd 'instal' 'Install a formula or cask'
|
||||
__fish_brew_complete_arg 'instal' -l HEAD -d 'If formula defines it, install the HEAD version, aka. main, trunk, unstable, master'
|
||||
__fish_brew_complete_arg 'instal' -l adopt -d 'Adopt existing artifacts in the destination that are identical to those being installed. Cannot be combined with `--force`'
|
||||
__fish_brew_complete_arg 'instal' -l appdir -d 'Target location for Applications (default: `/Applications`)'
|
||||
@ -1612,7 +1611,6 @@ __fish_brew_complete_arg 'unbottled' -l verbose -d 'Make some output more verbos
|
||||
__fish_brew_complete_arg 'unbottled' -a '(__fish_brew_suggest_formulae_all)'
|
||||
|
||||
|
||||
__fish_brew_complete_cmd 'uninstal' 'Uninstall a formula or cask'
|
||||
__fish_brew_complete_arg 'uninstal' -l cask -d 'Treat all named arguments as casks'
|
||||
__fish_brew_complete_arg 'uninstal' -l debug -d 'Display any debugging information'
|
||||
__fish_brew_complete_arg 'uninstal' -l force -d 'Delete all installed versions of formula. Uninstall even if cask is not installed, overwrite existing files and ignore errors when removing files'
|
||||
@ -1728,7 +1726,6 @@ __fish_brew_complete_arg 'update-python-resources' -l version -d 'Use the specif
|
||||
__fish_brew_complete_arg 'update-python-resources' -a '(__fish_brew_suggest_formulae_all)'
|
||||
|
||||
|
||||
__fish_brew_complete_cmd 'update-report' 'The Ruby implementation of `brew update`'
|
||||
__fish_brew_complete_arg 'update-report' -l auto-update -d 'Run in \'auto-update\' mode (faster, less output)'
|
||||
__fish_brew_complete_arg 'update-report' -l debug -d 'Display any debugging information'
|
||||
__fish_brew_complete_arg 'update-report' -l force -d 'Treat installed and updated formulae as if they are from the same taps and migrate them anyway'
|
||||
|
Loading…
Reference in New Issue
Block a user