Merge pull request #10133 from issyl0/constrain-brew-list-lrt-options-to-formulae-only

cmd/list: Constrain `-lrt` options to formulae
This commit is contained in:
Issy Long 2020-12-24 18:14:37 +00:00 committed by GitHub
commit 2424e58b91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -432,6 +432,10 @@ module Homebrew
@constraints.each do |primary, secondary, constraint_type| @constraints.each do |primary, secondary, constraint_type|
primary_passed = option_passed?(primary) primary_passed = option_passed?(primary)
secondary_passed = option_passed?(secondary) secondary_passed = option_passed?(secondary)
primary = name_to_option(primary)
secondary = name_to_option(secondary)
if :mandatory.equal?(constraint_type) && primary_passed && !secondary_passed if :mandatory.equal?(constraint_type) && primary_passed && !secondary_passed
raise OptionConstraintError.new(primary, secondary) raise OptionConstraintError.new(primary, secondary)
end end
@ -533,9 +537,6 @@ 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
"`#{arg2}` cannot be passed without `#{arg1}`." "`#{arg2}` cannot be passed without `#{arg1}`."
else else

View File

@ -47,11 +47,14 @@ 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."
conflicts "--formula", "--cask" conflicts "--formula", "--cask"