cmd/list.rb: --formula, --cask as default on TTY outputs

cmd/list.rb: --formula, --cask as default TTY:

cmd/list.rb: proper deprecated message on non TTY outputs

update manpage

update zsh completion

updated manpages/brew.1

update tests

return list_casks

list_spec.rb: not output to stderr
This commit is contained in:
Akylzhan Sauranbay 2020-10-05 00:49:53 +06:00
parent 5133b4cf89
commit c8809ce730
5 changed files with 26 additions and 12 deletions

View File

@ -33,9 +33,9 @@ module Homebrew
description: "Show the versions of pinned formulae, or only the specified (pinned) "\
"formulae if <formula> are provided. See also `pin`, `unpin`."
switch "--formula", "--formulae",
description: "List only formulae."
description: "List only formulae. `This is the default action on non TTY.`"
switch "--cask", "--casks",
description: "List only casks."
description: "List only casks, or <cask> if provided."
# passed through to ls
switch "-1",
description: "Force output to be one entry per line. " \
@ -86,7 +86,13 @@ module Homebrew
ls_args << "-r" if args.r?
ls_args << "-t" if args.t?
if !$stdout.tty? && !args.formula?
odeprecated "`brew list` to only list formulae", "`brew list --formula`"
safe_system "ls", *ls_args, HOMEBREW_CELLAR
else
safe_system "ls", *ls_args, HOMEBREW_CELLAR
list_casks(args: args) unless args.formula?
end
end
elsif args.verbose? || !$stdout.tty?
system_command! "find", args: args.named.to_kegs.map(&:to_s) + %w[-not -type d -print], print_stdout: true

View File

@ -14,7 +14,7 @@ describe "brew list", :integration_test do
(HOMEBREW_CELLAR/f/"1.0/somedir").mkpath
end
expect { brew "list" }
expect { brew "list", "--formula" }
.to output("#{formulae.join("\n")}\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success

View File

@ -62,10 +62,17 @@ __brew_formulae() {
__brew_installed_formulae() {
local -a formulae
formulae=($(brew list))
formulae=($(brew list --formula))
_describe -t formulae 'installed formulae' formulae
}
__brew_installed_casks() {
local -a list
local expl
list=( $(brew list --cask) )
_wanted list expl 'installed casks' compadd -a list
}
__brew_outdated_formulae() {
local -a formulae
formulae=($(brew outdated))
@ -493,11 +500,12 @@ _brew_linkage() {
# brew list, ls [--full-name]:
# brew list, ls --unbrewed:
# brew list, ls [--versions [--multiple]] [--pinned] [formulae]:
# brew list, ls --cask:
# brew list, ls [--cask|--formula]:
_brew_list() {
local state
_arguments \
- formulae \
'--formula[list install formulae]' \
'--full-name[print formulae with fully-qualified names]' \
'--unbrewed[files in brew --prefix not controlled by brew]' \
'--pinned[list all versions of pinned formulae]' \
@ -575,7 +583,7 @@ _brew_outdated() {
'--fetch-HEAD[detect if the HEAD installation of the formula is outdated]' \
- cask \
'--cask[list outdated Casks]' \
'--greedy[also list Casks with auto_updates or version \:latest]' \
'--greedy[also list Casks with auto_updates or version \:latest]'
}
# brew pin formulae:
@ -818,7 +826,7 @@ _brew_update_test() {
# install-options is copied from brew install
_brew_upgrade() {
_arguments \
'--cask[upgrade installed Casks with newer versions]'
'--cask[upgrade installed Casks with newer versions]' \
'--cleanup[remove previously installed formula version(s)]' \
'--fetch-HEAD[detect if the HEAD installation of the formula is outdated]' \
- normal-install \

View File

@ -424,9 +424,9 @@ If *`formula`* is provided, summarise the paths within its current keg.
* `--pinned`:
Show the versions of pinned formulae, or only the specified (pinned) formulae if *`formula`* are provided. See also `pin`, `unpin`.
* `--formula`:
List only formulae.
List only formulae. `This is the default action on non TTY.`
* `--cask`:
List only casks.
List only casks, or *`cask`* if provided.
* `-1`:
Force output to be one entry per line. This is the default when output is not to a terminal.
* `-l`:

View File

@ -653,11 +653,11 @@ Show the versions of pinned formulae, or only the specified (pinned) formulae if
.
.TP
\fB\-\-formula\fR
List only formulae\.
List only formulae\. \fBThis is the default action on non TTY\.\fR
.
.TP
\fB\-\-cask\fR
List only casks\.
List only casks, or \fIcask\fR if provided\.
.
.TP
\fB\-1\fR