All --cask for linux dev cmds

This ability was removed around a month
ago but needs to be added back in.

Developers want to be able to use the
`bump` and `audit` commands when on Linux.
This is especially useful for CI.
This commit is contained in:
apainintheneck 2023-01-07 21:22:47 -08:00
parent 918b47e24b
commit ad57705029
2 changed files with 15 additions and 5 deletions

View File

@ -122,8 +122,9 @@ module Homebrew
@args = Homebrew::CLI::Args.new
# Filter out Sorbet runtime type checking method calls.
@command_name = caller_locations.select { |location| location.path.exclude?("/gems/sorbet-runtime-") }
.second.label.chomp("_args").tr("_", "-")
cmd_location = caller_locations.select { |location| location.path.exclude?("/gems/sorbet-runtime-") }.second
@command_name = cmd_location.label.chomp("_args").tr("_", "-")
@is_dev_cmd = cmd_location.absolute_path.start_with?(Commands::HOMEBREW_DEV_CMD_PATH)
@constraints = []
@conflicts = []
@ -329,10 +330,11 @@ module Homebrew
remaining + non_options
end
set_default_options
unless ignore_invalid_options
validate_options
unless @is_dev_cmd
set_default_options
validate_options
end
check_constraint_violations
check_named_args(named_args)
end

View File

@ -577,6 +577,14 @@ describe Homebrew::CLI::Parser do
.and not_to_output.to_stdout
.and raise_exception SystemExit
end
# Developers want to be able to use `audit` and `bump`
# commands for formulae and casks on Linux.
it "succeeds for developer commands" do
require "dev-cmd/cat"
args = Homebrew.cat_args.parse(["--cask", "cask_name"])
expect(args.cask?).to be(true)
end
end
context "with conflicting --formula switch" do