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

View File

@ -577,6 +577,14 @@ describe Homebrew::CLI::Parser do
.and not_to_output.to_stdout .and not_to_output.to_stdout
.and raise_exception SystemExit .and raise_exception SystemExit
end 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 end
context "with conflicting --formula switch" do context "with conflicting --formula switch" do