Merge pull request #14450 from issyl0/casks-are-not-formulae

cli/parser: Don't treat args with `--cask` as formulae
This commit is contained in:
Issy Long 2023-01-31 00:07:06 +00:00 committed by GitHub
commit 79676ad20d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -298,9 +298,10 @@ module Homebrew
def parse(argv = ARGV.freeze, ignore_invalid_options: false)
raise "Arguments were already parsed!" if @args_parsed
# If we accept formula options, parse once allowing invalid options
# so we can get the remaining list containing formula names.
if @formula_options
# If we accept formula options, but the command isn't scoped only
# to casks, parse once allowing invalid options so we can get the
# remaining list containing formula names.
if @formula_options && !only_casks?(argv)
remaining, non_options = parse_remaining(argv, ignore_invalid_options: true)
argv = [*remaining, "--", *non_options]
@ -639,6 +640,10 @@ module Homebrew
end
end.compact.uniq(&:name)
end
def only_casks?(argv)
argv.include?("--casks") || argv.include?("--cask")
end
end
class OptionConstraintError < UsageError