Merge pull request #8851 from Akylzhan/patch
cmd/list.rb: --formula and --cask as default option on TTY
This commit is contained in:
		
						commit
						a0a9fa241f
					
				@ -34,9 +34,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. " \
 | 
			
		||||
@ -87,7 +87,13 @@ module Homebrew
 | 
			
		||||
        ls_args << "-r" if args.r?
 | 
			
		||||
        ls_args << "-t" if args.t?
 | 
			
		||||
 | 
			
		||||
        safe_system "ls", *ls_args, HOMEBREW_CELLAR
 | 
			
		||||
        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
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,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
 | 
			
		||||
 | 
			
		||||
@ -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:
 | 
			
		||||
 | 
			
		||||
@ -364,9 +364,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`:
 | 
			
		||||
 | 
			
		||||
@ -533,11 +533,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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user