Merge pull request #7949 from MLH-Fellowship/integrate-list

Allow listing casks when using brew list
This commit is contained in:
Mike McQuaid 2020-07-10 15:40:22 +01:00 committed by GitHub
commit da1efc46f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View File

@ -3,6 +3,7 @@
require "metafiles" require "metafiles"
require "formula" require "formula"
require "cli/parser" require "cli/parser"
require "cask/cmd"
module Homebrew module Homebrew
module_function module_function
@ -31,6 +32,8 @@ module Homebrew
switch "--pinned", switch "--pinned",
description: "Show the versions of pinned formulae, or only the specified (pinned) "\ description: "Show the versions of pinned formulae, or only the specified (pinned) "\
"formulae if <formula> are provided. See also `pin`, `unpin`." "formulae if <formula> are provided. See also `pin`, `unpin`."
switch "--cask",
description: "List casks"
# passed through to ls # passed through to ls
switch "-1", switch "-1",
description: "Force output to be one entry per line. " \ description: "Force output to be one entry per line. " \
@ -44,12 +47,15 @@ module Homebrew
description: "Sort by time modified, listing most recently modified first." description: "Sort by time modified, listing most recently modified first."
switch :verbose switch :verbose
switch :debug switch :debug
["--unbrewed", "--multiple", "--pinned", "-l", "-r", "-t"].each { |flag| conflicts "--cask", flag }
end end
end end
def list def list
list_args.parse list_args.parse
return list_casks if args.cask?
return list_unbrewed if args.unbrewed? return list_unbrewed if args.unbrewed?
# Unbrewed uses the PREFIX, which will exist # Unbrewed uses the PREFIX, which will exist
@ -150,6 +156,14 @@ module Homebrew
end end
end end
end end
def list_casks
cask_list = Cask::Cmd::List.new args.named
cask_list.one = ARGV.include? "-1"
cask_list.versions = args.versions?
cask_list.full_name = args.full_name?
cask_list.run
end
end end
class PrettyListing class PrettyListing

View File

@ -290,6 +290,8 @@ If *`formula`* is provided, summarise the paths within its current keg.
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`. Show the versions of pinned formulae, or only the specified (pinned) formulae if *`formula`* are provided. See also `pin`, `unpin`.
* `--cask`:
List casks
* `-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`:

View File

@ -393,6 +393,10 @@ Only show formulae with multiple versions installed\.
Show the versions of pinned formulae, or only the specified (pinned) formulae if \fIformula\fR are provided\. See also \fBpin\fR, \fBunpin\fR\. Show the versions of pinned formulae, or only the specified (pinned) formulae if \fIformula\fR are provided\. See also \fBpin\fR, \fBunpin\fR\.
. .
.TP .TP
\fB\-\-cask\fR
List casks
.
.TP
\fB\-1\fR \fB\-1\fR
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\.
. .