Deprecate global Homebrew.args.
This commit is contained in:
parent
6524802079
commit
536c963274
@ -1,5 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "compat/dependencies_helpers"
|
||||||
|
require "compat/cli/parser"
|
||||||
require "compat/extend/nil"
|
require "compat/extend/nil"
|
||||||
require "compat/extend/string"
|
require "compat/extend/string"
|
||||||
require "compat/formula"
|
require "compat/formula"
|
||||||
|
|||||||
32
Library/Homebrew/compat/cli/parser.rb
Normal file
32
Library/Homebrew/compat/cli/parser.rb
Normal 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
|
||||||
17
Library/Homebrew/compat/dependencies_helpers.rb
Normal file
17
Library/Homebrew/compat/dependencies_helpers.rb
Normal 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
|
||||||
Loading…
x
Reference in New Issue
Block a user