completions: complete files where appropriate in bash

This commit is contained in:
Rylan Polster 2021-01-18 13:30:47 -05:00
parent 67ca8f54a2
commit 4ef8c8279f
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64
7 changed files with 20 additions and 3 deletions

View File

@ -35,6 +35,7 @@ module Homebrew
installed_tap: "__brew_complete_tapped",
command: "__brew_complete_commands",
diagnostic_check: '__brewcomp "$(brew doctor --list-checks)"',
file: "__brew_complete_files",
}.freeze
sig { void }

View File

@ -117,6 +117,11 @@ __brew_complete_commands() {
COMPREPLY+=($(compgen -W "$cmds" -- "$cur"))
}
# compopt is only available in newer versions of bash
__brew_complete_files() {
command -v compopt &> /dev/null && compopt -o default
}
<%= completion_functions.join("\n") %>
_brew() {

View File

@ -85,7 +85,7 @@ module Homebrew
conflicts "--no-rebuild", "--keep-old"
named_args :installed_formula, min: 1
named_args [:installed_formula, :file], min: 1
end
end

View File

@ -20,6 +20,8 @@ module Homebrew
description: "Load a library using `require`."
flag "-e=",
description: "Execute the given text string as a script."
named_args :file
end
end

View File

@ -104,6 +104,11 @@ __brew_complete_commands() {
COMPREPLY+=($(compgen -W "$cmds" -- "$cur"))
}
# compopt is only available in newer versions of bash
__brew_complete_files() {
command -v compopt &> /dev/null && compopt -o default
}
_brew___cache() {
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
@ -413,6 +418,7 @@ _brew_bottle() {
;;
esac
__brew_complete_installed_formulae
__brew_complete_files
}
_brew_bump() {
@ -1732,6 +1738,7 @@ _brew_ruby() {
return
;;
esac
__brew_complete_files
}
_brew_search() {
@ -1776,6 +1783,7 @@ _brew_sh() {
return
;;
esac
__brew_complete_files
}
_brew_sponsors() {
@ -1813,6 +1821,7 @@ _brew_style() {
return
;;
esac
__brew_complete_files
__brew_complete_tapped
__brew_complete_formulae
__brew_complete_casks

View File

@ -794,7 +794,7 @@ non-zero status if any errors are found.
* `--token-conflicts`:
Audit for token conflicts
### `bottle` [*`options`*] *`installed_formula`* [...]
### `bottle` [*`options`*] *`installed_formula`*|*`file`* [...]
Generate a bottle (binary package) from a formula that was installed with
`--build-bottle`.

View File

@ -1085,7 +1085,7 @@ Audit the appcast
\fB\-\-token\-conflicts\fR
Audit for token conflicts
.
.SS "\fBbottle\fR [\fIoptions\fR] \fIinstalled_formula\fR [\.\.\.]"
.SS "\fBbottle\fR [\fIoptions\fR] \fIinstalled_formula\fR|\fIfile\fR [\.\.\.]"
Generate a bottle (binary package) from a formula that was installed with \fB\-\-build\-bottle\fR\. If the formula specifies a rebuild version, it will be incremented in the generated DSL\. Passing \fB\-\-keep\-old\fR will attempt to keep it at its original value, while \fB\-\-no\-rebuild\fR will remove it\.
.
.TP