mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
list: deprecate --unbrewed
in favour of brew --prefix --unbrewed
This commit is contained in:
parent
b7aae0c643
commit
c65d4617bd
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: false
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
@ -14,19 +14,28 @@ module Homebrew
|
|||||||
usage_banner <<~EOS
|
usage_banner <<~EOS
|
||||||
`--prefix` [<formula>]
|
`--prefix` [<formula>]
|
||||||
|
|
||||||
Display Homebrew's install path. *Default:* `/usr/local` on macOS and
|
Display Homebrew's install path. *Default:*
|
||||||
`/home/linuxbrew/.linuxbrew` on Linux.
|
|
||||||
|
- 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>
|
If <formula> is provided, display the location in the Cellar where <formula>
|
||||||
is or would be installed.
|
is or would be installed.
|
||||||
EOS
|
EOS
|
||||||
|
switch "--unbrewed",
|
||||||
|
description: "List files in Homebrew's prefix not installed by Homebrew."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def __prefix
|
def __prefix
|
||||||
args = __prefix_args.parse
|
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
|
puts HOMEBREW_PREFIX
|
||||||
else
|
else
|
||||||
puts args.named.to_resolved_formulae.map { |f|
|
puts args.named.to_resolved_formulae.map { |f|
|
||||||
@ -34,4 +43,47 @@ module Homebrew
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
@ -27,7 +27,8 @@ module Homebrew
|
|||||||
switch "--cask", "--casks",
|
switch "--cask", "--casks",
|
||||||
description: "List only casks, or treat all named arguments as casks."
|
description: "List only casks, or treat all named arguments as casks."
|
||||||
switch "--unbrewed",
|
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",
|
switch "--full-name",
|
||||||
description: "Print formulae with fully-qualified names. Unless `--full-name`, `--versions` "\
|
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 "\
|
"or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are "\
|
||||||
@ -75,12 +76,6 @@ module Homebrew
|
|||||||
def list
|
def list
|
||||||
args = list_args.parse
|
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
|
# Unbrewed uses the PREFIX, which will exist
|
||||||
# Things below use the CELLAR, which doesn't until the first formula is installed.
|
# Things below use the CELLAR, which doesn't until the first formula is installed.
|
||||||
unless HOMEBREW_CELLAR.exist?
|
unless HOMEBREW_CELLAR.exist?
|
||||||
@ -133,49 +128,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
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:)
|
def filtered_list(args:)
|
||||||
names = if args.no_named?
|
names = if args.no_named?
|
||||||
Formula.racks
|
Formula.racks
|
||||||
|
@ -313,21 +313,20 @@ installations.
|
|||||||
List all installed formulae and casks.
|
List all installed formulae and casks.
|
||||||
|
|
||||||
If *`formula`* is provided, summarise the paths within its current keg.
|
If *`formula`* is provided, summarise the paths within its current keg.
|
||||||
|
If *`cask`* is provided, list its artifacts.
|
||||||
|
|
||||||
* `--formula`:
|
* `--formula`:
|
||||||
List only formulae.
|
List only formulae, or treat all named arguments as formulae.
|
||||||
* `--cask`:
|
* `--cask`:
|
||||||
List only casks, or *`cask`* if provided.
|
List only casks, or treat all named arguments as casks.
|
||||||
* `--unbrewed`:
|
|
||||||
List files in Homebrew's prefix not installed by Homebrew.
|
|
||||||
* `--full-name`:
|
* `--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`:
|
* `--versions`:
|
||||||
Show the version number for installed formulae, or only the specified formulae if *`formula`* are provided.
|
Show the version number for installed formulae, or only the specified formulae if *`formula`* are provided.
|
||||||
* `--multiple`:
|
* `--multiple`:
|
||||||
Only show formulae with multiple versions installed.
|
Only show formulae with multiple versions installed.
|
||||||
* `--pinned`:
|
* `--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`:
|
* `-1`:
|
||||||
Force output to be one entry per line. This is the default when output is not to a terminal.
|
Force output to be one entry per line. This is the default when output is not to a terminal.
|
||||||
* `-l`:
|
* `-l`:
|
||||||
@ -696,12 +695,18 @@ the list is formatted for export to `bash`(1) unless `--plain` is passed.
|
|||||||
|
|
||||||
### `--prefix` [*`formula`*]
|
### `--prefix` [*`formula`*]
|
||||||
|
|
||||||
Display Homebrew's install path. *Default:* `/usr/local` on macOS and
|
Display Homebrew's install path. *Default:*
|
||||||
`/home/linuxbrew/.linuxbrew` on Linux.
|
|
||||||
|
- macOS Intel: `/usr/local`
|
||||||
|
- macOS ARM: `/opt/homebrew`
|
||||||
|
- Linux: `/home/linuxbrew/.linuxbrew`
|
||||||
|
|
||||||
If *`formula`* is provided, display the location in the Cellar where *`formula`*
|
If *`formula`* is provided, display the location in the Cellar where *`formula`*
|
||||||
is or would be installed.
|
is or would be installed.
|
||||||
|
|
||||||
|
* `--unbrewed`:
|
||||||
|
List files in Homebrew's prefix not installed by Homebrew.
|
||||||
|
|
||||||
### `--repository`, `--repo` [*`user`*`/`*`repo`*]
|
### `--repository`, `--repo` [*`user`*`/`*`repo`*]
|
||||||
|
|
||||||
Display where Homebrew's `.git` directory is located.
|
Display where Homebrew's `.git` directory is located.
|
||||||
|
@ -420,23 +420,19 @@ Allow keg\-only formulae to be linked\.
|
|||||||
List all installed formulae and casks\.
|
List all installed formulae and casks\.
|
||||||
.
|
.
|
||||||
.P
|
.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
|
.TP
|
||||||
\fB\-\-formula\fR
|
\fB\-\-formula\fR
|
||||||
List only formulae\.
|
List only formulae, or treat all named arguments as formulae\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-cask\fR
|
\fB\-\-cask\fR
|
||||||
List only casks, or \fIcask\fR if provided\.
|
List only casks, or treat all named arguments as casks\.
|
||||||
.
|
|
||||||
.TP
|
|
||||||
\fB\-\-unbrewed\fR
|
|
||||||
List files in Homebrew\'s prefix not installed by Homebrew\.
|
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-full\-name\fR
|
\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
|
.TP
|
||||||
\fB\-\-versions\fR
|
\fB\-\-versions\fR
|
||||||
@ -448,7 +444,7 @@ Only show formulae with multiple versions installed\.
|
|||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-pinned\fR
|
\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
|
.TP
|
||||||
\fB\-1\fR
|
\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\.
|
Generate plain output even when piped\.
|
||||||
.
|
.
|
||||||
.SS "\fB\-\-prefix\fR [\fIformula\fR]"
|
.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
|
.P
|
||||||
If \fIformula\fR is provided, display the location in the Cellar where \fIformula\fR is or would be installed\.
|
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]"
|
.SS "\fB\-\-repository\fR, \fB\-\-repo\fR [\fIuser\fR\fB/\fR\fIrepo\fR]"
|
||||||
Display where Homebrew\'s \fB\.git\fR directory is located\.
|
Display where Homebrew\'s \fB\.git\fR directory is located\.
|
||||||
.
|
.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user