Deprecate global Homebrew.args.

This commit is contained in:
Markus Reiter 2020-08-06 16:14:07 +02:00
parent 6524802079
commit 536c963274
3 changed files with 51 additions and 0 deletions

View File

@ -1,5 +1,7 @@
# frozen_string_literal: true
require "compat/dependencies_helpers"
require "compat/cli/parser"
require "compat/extend/nil"
require "compat/extend/string"
require "compat/formula"

View File

@ -0,0 +1,32 @@
# frozen_string_literal: true
module Homebrew
module CLI
class Parser
module Compat
module DeprecatedArgs
def respond_to_missing?(*)
super
end
def method_missing(method, *)
if ![:debug?, :quiet?, :verbose?].include?(method) && !@printed_args_warning
odeprecated "Homebrew.args", "`args = <command>_args.parse` and pass `args` along the call chain"
@printed_args_warning = true
end
super
end
end
def parse(*)
args = super
Homebrew.args = args.dup.extend(DeprecatedArgs)
args
end
end
prepend Compat
end
end
end

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
require "cli/args"
module DependenciesHelpers
module Compat
def argv_includes_ignores(argv = nil)
unless @printed_includes_ignores_warning
odeprecated "Homebrew.argv_includes_ignores", "Homebrew.args_includes_ignores"
@printed_includes_ignores_warning = true
end
args_includes_ignores(argv ? Homebrew::CLI::Args.new : Homebrew.args)
end
end
prepend Compat
end