cli/parser: Casks can be specified with --cask or --casks

This commit is contained in:
Issy Long 2023-01-28 12:54:48 +00:00
parent 8881ea74b5
commit 1ce6a38730
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -301,7 +301,7 @@ module Homebrew
# 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 && argv.exclude?("--cask")
if @formula_options && !only_casks?(argv)
remaining, non_options = parse_remaining(argv, ignore_invalid_options: true)
argv = [*remaining, "--", *non_options]
@ -640,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