list: deprecate --unbrewed in favour of brew --prefix --unbrewed

This commit is contained in:
EricFromCanada 2020-11-30 08:41:48 -05:00 committed by Mike McQuaid
parent b7aae0c643
commit c65d4617bd
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
4 changed files with 92 additions and 72 deletions

View File

@ -1,4 +1,4 @@
# typed: true
# typed: false
# frozen_string_literal: true
require "cli/parser"
@ -14,19 +14,28 @@ module Homebrew
usage_banner <<~EOS
`--prefix` [<formula>]
Display Homebrew's install path. *Default:* `/usr/local` on macOS and
`/home/linuxbrew/.linuxbrew` on Linux.
Display Homebrew's install path. *Default:*
- macOS Intel: `#{HOMEBREW_DEFAULT_PREFIX}`
- macOS ARM: `#{HOMEBREW_MACOS_ARM_DEFAULT_PREFIX}`
- Linux: `#{HOMEBREW_LINUX_DEFAULT_PREFIX}`
If <formula> is provided, display the location in the Cellar where <formula>
is or would be installed.
EOS
switch "--unbrewed",
description: "List files in Homebrew's prefix not installed by Homebrew."
end
end
def __prefix
args = __prefix_args.parse
if args.no_named?
if args.unbrewed?
raise UsageError, "`--unbrewed` does not take a formula argument." unless args.no_named?
list_unbrewed
elsif args.no_named?
puts HOMEBREW_PREFIX
else
puts args.named.to_resolved_formulae.map { |f|
@ -34,4 +43,47 @@ module Homebrew
}
end
end
UNBREWED_EXCLUDE_FILES = %w[.DS_Store].freeze
UNBREWED_EXCLUDE_PATHS = %w[
*/.keepme
.github/*
bin/brew
completions/zsh/_brew
docs/*
lib/gdk-pixbuf-2.0/*
lib/gio/*
lib/node_modules/*
lib/python[23].[0-9]/*
lib/pypy/*
lib/pypy3/*
lib/ruby/gems/[12].*
lib/ruby/site_ruby/[12].*
lib/ruby/vendor_ruby/[12].*
manpages/brew.1
share/pypy/*
share/pypy3/*
share/info/dir
share/man/whatis
].freeze
def list_unbrewed
dirs = HOMEBREW_PREFIX.subdirs.map { |dir| dir.basename.to_s }
dirs -= %w[Library Cellar Caskroom .git]
# Exclude cache, logs, and repository, if they are located under the prefix.
[HOMEBREW_CACHE, HOMEBREW_LOGS, HOMEBREW_REPOSITORY].each do |dir|
dirs.delete dir.relative_path_from(HOMEBREW_PREFIX).to_s
end
dirs.delete "etc"
dirs.delete "var"
arguments = dirs.sort + %w[-type f (]
arguments.concat UNBREWED_EXCLUDE_FILES.flat_map { |f| %W[! -name #{f}] }
arguments.concat UNBREWED_EXCLUDE_PATHS.flat_map { |d| %W[! -path #{d}] }
arguments.concat %w[)]
cd HOMEBREW_PREFIX
safe_system "find", *arguments
end
end

View File

@ -27,7 +27,8 @@ module Homebrew
switch "--cask", "--casks",
description: "List only casks, or treat all named arguments as casks."
switch "--unbrewed",
description: "List files in Homebrew's prefix not installed by Homebrew."
description: "List files in Homebrew's prefix not installed by Homebrew.",
replacement: "`brew --prefix --unbrewed`"
switch "--full-name",
description: "Print formulae with fully-qualified names. Unless `--full-name`, `--versions` "\
"or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are "\
@ -75,12 +76,6 @@ module Homebrew
def list
args = list_args.parse
if args.unbrewed?
raise UsageError, "`--unbrewed` does not take a formula/cask argument." unless args.no_named?
return list_unbrewed
end
# Unbrewed uses the PREFIX, which will exist
# Things below use the CELLAR, which doesn't until the first formula is installed.
unless HOMEBREW_CELLAR.exist?
@ -133,49 +128,6 @@ module Homebrew
end
end
UNBREWED_EXCLUDE_FILES = %w[.DS_Store].freeze
UNBREWED_EXCLUDE_PATHS = %w[
*/.keepme
.github/*
bin/brew
completions/zsh/_brew
docs/*
lib/gdk-pixbuf-2.0/*
lib/gio/*
lib/node_modules/*
lib/python[23].[0-9]/*
lib/pypy/*
lib/pypy3/*
lib/ruby/gems/[12].*
lib/ruby/site_ruby/[12].*
lib/ruby/vendor_ruby/[12].*
manpages/brew.1
share/pypy/*
share/pypy3/*
share/info/dir
share/man/whatis
].freeze
def list_unbrewed
dirs = HOMEBREW_PREFIX.subdirs.map { |dir| dir.basename.to_s }
dirs -= %w[Library Cellar Caskroom .git]
# Exclude cache, logs, and repository, if they are located under the prefix.
[HOMEBREW_CACHE, HOMEBREW_LOGS, HOMEBREW_REPOSITORY].each do |dir|
dirs.delete dir.relative_path_from(HOMEBREW_PREFIX).to_s
end
dirs.delete "etc"
dirs.delete "var"
arguments = dirs.sort + %w[-type f (]
arguments.concat UNBREWED_EXCLUDE_FILES.flat_map { |f| %W[! -name #{f}] }
arguments.concat UNBREWED_EXCLUDE_PATHS.flat_map { |d| %W[! -path #{d}] }
arguments.concat %w[)]
cd HOMEBREW_PREFIX
safe_system "find", *arguments
end
def filtered_list(args:)
names = if args.no_named?
Formula.racks

View File

@ -313,21 +313,20 @@ installations.
List all installed formulae and casks.
If *`formula`* is provided, summarise the paths within its current keg.
If *`cask`* is provided, list its artifacts.
* `--formula`:
List only formulae.
List only formulae, or treat all named arguments as formulae.
* `--cask`:
List only casks, or *`cask`* if provided.
* `--unbrewed`:
List files in Homebrew's prefix not installed by Homebrew.
List only casks, or treat all named arguments as casks.
* `--full-name`:
Print formulae with fully-qualified names. If `--full-name` is not passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output.
Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output.
* `--versions`:
Show the version number for installed formulae, or only the specified formulae if *`formula`* are provided.
* `--multiple`:
Only show formulae with multiple versions installed.
* `--pinned`:
Show the versions of pinned formulae, or only the specified (pinned) formulae if *`formula`* are provided. See also `pin`, `unpin`.
List only pinned formulae, or only the specified (pinned) formulae if *`formula`* are provided. See also `pin`, `unpin`.
* `-1`:
Force output to be one entry per line. This is the default when output is not to a terminal.
* `-l`:
@ -696,12 +695,18 @@ the list is formatted for export to `bash`(1) unless `--plain` is passed.
### `--prefix` [*`formula`*]
Display Homebrew's install path. *Default:* `/usr/local` on macOS and
`/home/linuxbrew/.linuxbrew` on Linux.
Display Homebrew's install path. *Default:*
- macOS Intel: `/usr/local`
- macOS ARM: `/opt/homebrew`
- Linux: `/home/linuxbrew/.linuxbrew`
If *`formula`* is provided, display the location in the Cellar where *`formula`*
is or would be installed.
* `--unbrewed`:
List files in Homebrew's prefix not installed by Homebrew.
### `--repository`, `--repo` [*`user`*`/`*`repo`*]
Display where Homebrew's `.git` directory is located.

View File

@ -420,23 +420,19 @@ Allow keg\-only formulae to be linked\.
List all installed formulae and casks\.
.
.P
If \fIformula\fR is provided, summarise the paths within its current keg\.
If \fIformula\fR is provided, summarise the paths within its current keg\. If \fIcask\fR is provided, list its artifacts\.
.
.TP
\fB\-\-formula\fR
List only formulae\.
List only formulae, or treat all named arguments as formulae\.
.
.TP
\fB\-\-cask\fR
List only casks, or \fIcask\fR if provided\.
.
.TP
\fB\-\-unbrewed\fR
List files in Homebrew\'s prefix not installed by Homebrew\.
List only casks, or treat all named arguments as casks\.
.
.TP
\fB\-\-full\-name\fR
Print formulae with fully\-qualified names\. If \fB\-\-full\-name\fR is not passed, other options (i\.e\. \fB\-1\fR, \fB\-l\fR, \fB\-r\fR and \fB\-t\fR) are passed to \fBls\fR(1) which produces the actual output\.
Print formulae with fully\-qualified names\. Unless \fB\-\-full\-name\fR, \fB\-\-versions\fR or \fB\-\-pinned\fR are passed, other options (i\.e\. \fB\-1\fR, \fB\-l\fR, \fB\-r\fR and \fB\-t\fR) are passed to \fBls\fR(1) which produces the actual output\.
.
.TP
\fB\-\-versions\fR
@ -448,7 +444,7 @@ Only show formulae with multiple versions installed\.
.
.TP
\fB\-\-pinned\fR
Show the versions of pinned formulae, or only the specified (pinned) formulae if \fIformula\fR are provided\. See also \fBpin\fR, \fBunpin\fR\.
List only pinned formulae, or only the specified (pinned) formulae if \fIformula\fR are provided\. See also \fBpin\fR, \fBunpin\fR\.
.
.TP
\fB\-1\fR
@ -941,11 +937,26 @@ Generate a list of environment variables for the specified shell, or \fB\-\-shel
Generate plain output even when piped\.
.
.SS "\fB\-\-prefix\fR [\fIformula\fR]"
Display Homebrew\'s install path\. \fIDefault:\fR \fB/usr/local\fR on macOS and \fB/home/linuxbrew/\.linuxbrew\fR on Linux\.
Display Homebrew\'s install path\. \fIDefault:\fR
.
.IP "\(bu" 4
macOS Intel: \fB/usr/local\fR
.
.IP "\(bu" 4
macOS ARM: \fB/opt/homebrew\fR
.
.IP "\(bu" 4
Linux: \fB/home/linuxbrew/\.linuxbrew\fR
.
.IP "" 0
.
.P
If \fIformula\fR is provided, display the location in the Cellar where \fIformula\fR is or would be installed\.
.
.TP
\fB\-\-unbrewed\fR
List files in Homebrew\'s prefix not installed by Homebrew\.
.
.SS "\fB\-\-repository\fR, \fB\-\-repo\fR [\fIuser\fR\fB/\fR\fIrepo\fR]"
Display where Homebrew\'s \fB\.git\fR directory is located\.
.