diff --git a/Library/Homebrew/cli_parser.rb b/Library/Homebrew/cli_parser.rb index d4e4ebb7e1..f35328a574 100644 --- a/Library/Homebrew/cli_parser.rb +++ b/Library/Homebrew/cli_parser.rb @@ -52,7 +52,7 @@ module Homebrew end process_option(*names, description) @parser.on(*names, *wrap_option_desc(description)) do - enable_switch(*names) + enable_switch(*names, from: :args) end names.each do |name| @@ -173,7 +173,7 @@ module Homebrew private - def enable_switch(*names, from: :arg) + def enable_switch(*names, from:) names.each do |name| @switch_sources[option_to_name(name)] = from Homebrew.args["#{option_to_name(name)}?"] = true diff --git a/Library/Homebrew/test/cli_parser_spec.rb b/Library/Homebrew/test/cli_parser_spec.rb index caaa71d78f..53504dd287 100644 --- a/Library/Homebrew/test/cli_parser_spec.rb +++ b/Library/Homebrew/test/cli_parser_spec.rb @@ -181,6 +181,7 @@ describe Homebrew::CLI::Parser do it "prioritizes cli arguments over env vars when they conflict" do allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_A").and_return("1") allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_B").and_return("0") + allow(ENV).to receive(:[]) parser.parse(["--switch-b"]) expect(Homebrew.args.switch_a?).to be_falsy expect(Homebrew.args.switch_b?).to be true