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: complete files where appropriate in bash #10360

Merged
merged 1 commit into from Jan 20, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Library/Homebrew/completions.rb
Expand Up @@ -35,6 +35,7 @@ module Completions
installed_tap: "__brew_complete_tapped",
command: "__brew_complete_commands",
diagnostic_check: '__brewcomp "$(brew doctor --list-checks)"',
file: "__brew_complete_files",
}.freeze

sig { void }
Expand Down
5 changes: 5 additions & 0 deletions Library/Homebrew/completions/bash.erb
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/bottle.rb
Expand Up @@ -85,7 +85,7 @@ def bottle_args

conflicts "--no-rebuild", "--keep-old"

named_args :installed_formula, min: 1
named_args [:installed_formula, :file], min: 1
end
end

Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/dev-cmd/ruby.rb
Expand Up @@ -20,6 +20,8 @@ def ruby_args
description: "Load a library using `require`."
flag "-e=",
description: "Execute the given text string as a script."

named_args :file
end
end

Expand Down
9 changes: 9 additions & 0 deletions completions/bash/brew
Expand Up @@ -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
Expand Down Expand Up @@ -413,6 +418,7 @@ _brew_bottle() {
;;
esac
__brew_complete_installed_formulae
__brew_complete_files
}

_brew_bump() {
Expand Down Expand Up @@ -1732,6 +1738,7 @@ _brew_ruby() {
return
;;
esac
__brew_complete_files
}

_brew_search() {
Expand Down Expand Up @@ -1776,6 +1783,7 @@ _brew_sh() {
return
;;
esac
__brew_complete_files
}

_brew_sponsors() {
Expand Down Expand Up @@ -1813,6 +1821,7 @@ _brew_style() {
return
;;
esac
__brew_complete_files
__brew_complete_tapped
__brew_complete_formulae
__brew_complete_casks
Expand Down
2 changes: 1 addition & 1 deletion docs/Manpage.md
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion manpages/brew.1
Expand Up @@ -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
Expand Down