Pass args to Analytics instead of using global args.
This commit is contained in:
parent
25b3632c4c
commit
6c050492ee
@ -46,7 +46,7 @@ module Cask
|
|||||||
|
|
||||||
def self.info(cask)
|
def self.info(cask)
|
||||||
puts get_info(cask)
|
puts get_info(cask)
|
||||||
::Utils::Analytics.cask_output(cask)
|
::Utils::Analytics.cask_output(cask, args: Homebrew::CLI::Args.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.title_info(cask)
|
def self.title_info(cask)
|
||||||
|
|||||||
@ -96,7 +96,7 @@ module Homebrew
|
|||||||
def print_info
|
def print_info
|
||||||
if args.no_named?
|
if args.no_named?
|
||||||
if args.analytics?
|
if args.analytics?
|
||||||
Utils::Analytics.output
|
Utils::Analytics.output(args: args)
|
||||||
elsif HOMEBREW_CELLAR.exist?
|
elsif HOMEBREW_CELLAR.exist?
|
||||||
count = Formula.racks.length
|
count = Formula.racks.length
|
||||||
puts "#{count} #{"keg".pluralize(count)}, #{HOMEBREW_CELLAR.dup.abv}"
|
puts "#{count} #{"keg".pluralize(count)}, #{HOMEBREW_CELLAR.dup.abv}"
|
||||||
@ -107,13 +107,13 @@ module Homebrew
|
|||||||
begin
|
begin
|
||||||
formula = Formulary.factory(f)
|
formula = Formulary.factory(f)
|
||||||
if args.analytics?
|
if args.analytics?
|
||||||
Utils::Analytics.formula_output(formula)
|
Utils::Analytics.formula_output(formula, args: args)
|
||||||
else
|
else
|
||||||
info_formula(formula)
|
info_formula(formula, args: args)
|
||||||
end
|
end
|
||||||
rescue FormulaUnavailableError => e
|
rescue FormulaUnavailableError => e
|
||||||
if args.analytics?
|
if args.analytics?
|
||||||
Utils::Analytics.output(filter: f)
|
Utils::Analytics.output(filter: f, args: args)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
ofail e.message
|
ofail e.message
|
||||||
@ -159,7 +159,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def info_formula(f)
|
def info_formula(f, args:)
|
||||||
specs = []
|
specs = []
|
||||||
|
|
||||||
if stable = f.stable
|
if stable = f.stable
|
||||||
@ -239,7 +239,7 @@ module Homebrew
|
|||||||
caveats = Caveats.new(f)
|
caveats = Caveats.new(f)
|
||||||
ohai "Caveats", caveats.to_s unless caveats.empty?
|
ohai "Caveats", caveats.to_s unless caveats.empty?
|
||||||
|
|
||||||
Utils::Analytics.formula_output(f)
|
Utils::Analytics.formula_output(f, args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def decorate_dependencies(dependencies)
|
def decorate_dependencies(dependencies)
|
||||||
|
|||||||
@ -116,9 +116,9 @@ module Utils
|
|||||||
config_delete(:analyticsuuid)
|
config_delete(:analyticsuuid)
|
||||||
end
|
end
|
||||||
|
|
||||||
def output(filter: nil)
|
def output(filter: nil, args:)
|
||||||
days = Homebrew.args.days || "30"
|
days = args.days || "30"
|
||||||
category = Homebrew.args.category || "install"
|
category = args.category || "install"
|
||||||
json = formulae_brew_sh_json("analytics/#{category}/#{days}d.json")
|
json = formulae_brew_sh_json("analytics/#{category}/#{days}d.json")
|
||||||
return if json.blank? || json["items"].blank?
|
return if json.blank? || json["items"].blank?
|
||||||
|
|
||||||
@ -147,8 +147,8 @@ module Utils
|
|||||||
table_output(category, days, results, os_version: os_version, cask_install: cask_install)
|
table_output(category, days, results, os_version: os_version, cask_install: cask_install)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_analytics(json)
|
def get_analytics(json, args:)
|
||||||
full_analytics = Homebrew.args.analytics? || Homebrew.args.verbose?
|
full_analytics = args.analytics? || Homebrew.args.verbose?
|
||||||
|
|
||||||
ohai "Analytics"
|
ohai "Analytics"
|
||||||
json["analytics"].each do |category, value|
|
json["analytics"].each do |category, value|
|
||||||
@ -158,11 +158,11 @@ module Utils
|
|||||||
value.each do |days, results|
|
value.each do |days, results|
|
||||||
days = days.to_i
|
days = days.to_i
|
||||||
if full_analytics
|
if full_analytics
|
||||||
if Homebrew.args.days.present?
|
if args.days.present?
|
||||||
next if Homebrew.args.days&.to_i != days
|
next if args.days&.to_i != days
|
||||||
end
|
end
|
||||||
if Homebrew.args.category.present?
|
if args.category.present?
|
||||||
next if Homebrew.args.category != category
|
next if args.category != category
|
||||||
end
|
end
|
||||||
|
|
||||||
table_output(category, days, results)
|
table_output(category, days, results)
|
||||||
@ -176,18 +176,18 @@ module Utils
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def formula_output(f)
|
def formula_output(f, args:)
|
||||||
json = formulae_brew_sh_json("#{formula_path}/#{f}.json")
|
json = formulae_brew_sh_json("#{formula_path}/#{f}.json")
|
||||||
return if json.blank? || json["analytics"].blank?
|
return if json.blank? || json["analytics"].blank?
|
||||||
|
|
||||||
get_analytics(json)
|
get_analytics(json, args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def cask_output(cask)
|
def cask_output(cask, args:)
|
||||||
json = formulae_brew_sh_json("#{cask_path}/#{cask}.json")
|
json = formulae_brew_sh_json("#{cask_path}/#{cask}.json")
|
||||||
return if json.blank? || json["analytics"].blank?
|
return if json.blank? || json["analytics"].blank?
|
||||||
|
|
||||||
get_analytics(json)
|
get_analytics(json, args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_prefix_label
|
def custom_prefix_label
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user