Skip to content

Commit

Permalink
Merge pull request #16043 from MikeMcQuaid/cli_parser_env_external_co…
Browse files Browse the repository at this point in the history
…mmands

cli/parser: check env var directly if there's no `EnvConfig` method.
  • Loading branch information
MikeMcQuaid committed Sep 27, 2023
2 parents c2841e2 + 58f8832 commit d799bd4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Library/Homebrew/cli/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,12 @@ def switch(*names, description: nil, replacement: nil, env: nil, depends_on: nil
def env?(env)
return if env.blank?

Homebrew::EnvConfig.try(:"#{env}?")
method_name = :"#{env}?"
if Homebrew::EnvConfig.respond_to?(method_name)
Homebrew::EnvConfig.public_send(method_name)
else
ENV.fetch("HOMEBREW_#{env.upcase}", nil)
end
end

def description(text = nil)
Expand Down

0 comments on commit d799bd4

Please sign in to comment.