Merge pull request #9038 from MikeMcQuaid/ls-flags-again

list: more parameters fixes.
This commit is contained in:
Mike McQuaid 2020-11-03 17:30:52 +00:00 committed by GitHub
commit 4a505fce31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -508,6 +508,9 @@ module Homebrew
class OptionConstraintError < UsageError class OptionConstraintError < UsageError
def initialize(arg1, arg2, missing: false) def initialize(arg1, arg2, missing: false)
arg1 = "--#{arg1.tr("_", "-")}"
arg2 = "--#{arg2.tr("_", "-")}"
message = if !missing message = if !missing
"`#{arg1}` and `#{arg2}` should be passed together." "`#{arg1}` and `#{arg2}` should be passed together."
else else

View File

@ -30,14 +30,12 @@ module Homebrew
"passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) "\ "passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) "\
"which produces the actual output." "which produces the actual output."
switch "--versions", switch "--versions",
depends_on: "--formula",
description: "Show the version number for installed formulae, or only the specified "\ description: "Show the version number for installed formulae, or only the specified "\
"formulae if <formula> are provided." "formulae if <formula> are provided."
switch "--multiple", switch "--multiple",
depends_on: "--versions", depends_on: "--versions",
description: "Only show formulae with multiple versions installed." description: "Only show formulae with multiple versions installed."
switch "--pinned", switch "--pinned",
depends_on: "--formula",
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`."
# passed through to ls # passed through to ls
@ -45,14 +43,11 @@ module Homebrew
description: "Force output to be one entry per line. " \ description: "Force output to be one entry per line. " \
"This is the default when output is not to a terminal." "This is the default when output is not to a terminal."
switch "-l", switch "-l",
depends_on: "--formula",
description: "List formulae in long format. If the output is to a terminal, "\ description: "List formulae in long format. If the output is to a terminal, "\
"a total sum for all the file sizes is printed before the long listing." "a total sum for all the file sizes is printed before the long listing."
switch "-r", switch "-r",
depends_on: "--formula",
description: "Reverse the order of the formulae sort to list the oldest entries first." description: "Reverse the order of the formulae sort to list the oldest entries first."
switch "-t", switch "-t",
depends_on: "--formula",
description: "Sort formulae by time modified, listing most recently modified first." description: "Sort formulae by time modified, listing most recently modified first."
["-1", "-l", "-r", "-t"].each do |flag| ["-1", "-l", "-r", "-t"].each do |flag|
@ -73,7 +68,11 @@ module Homebrew
return list_casks(args: args) if args.cask? return list_casks(args: args) if args.cask?
return list_unbrewed if args.unbrewed? 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.