2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-04-17 18:25:08 +09:00
|
|
|
require "cli/parser"
|
2019-01-20 20:04:19 +05:30
|
|
|
|
2016-05-01 22:04:46 +08:00
|
|
|
module Homebrew
|
2016-09-26 01:44:51 +02:00
|
|
|
module_function
|
|
|
|
|
2019-01-20 20:04:19 +05:30
|
|
|
def analytics_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
|
|
|
usage_banner <<~EOS
|
2019-08-06 14:17:17 -04:00
|
|
|
`analytics` [<subcommand>]
|
2019-01-20 20:04:19 +05:30
|
|
|
|
2019-03-09 13:00:15 -05:00
|
|
|
If `on` or `off` is passed, turn Homebrew's analytics on or off respectively.
|
2019-01-20 20:04:19 +05:30
|
|
|
|
2019-08-20 00:04:14 -04:00
|
|
|
If `state` is passed, display the current anonymous user behaviour analytics state.
|
2019-01-20 20:04:19 +05:30
|
|
|
Read more at <https://docs.brew.sh/Analytics>.
|
|
|
|
|
2019-08-06 14:22:24 -04:00
|
|
|
If `regenerate-uuid` is passed, regenerate the UUID used in Homebrew's analytics.
|
2019-01-20 20:04:19 +05:30
|
|
|
EOS
|
|
|
|
switch :verbose
|
|
|
|
switch :debug
|
2019-12-13 16:50:54 -05:00
|
|
|
max_named 1
|
2019-01-20 20:04:19 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-01 22:04:46 +08:00
|
|
|
def analytics
|
2019-01-20 20:04:19 +05:30
|
|
|
analytics_args.parse
|
2016-05-01 22:04:46 +08:00
|
|
|
|
2020-03-04 17:28:15 +00:00
|
|
|
case args.named.first
|
2016-05-01 22:04:46 +08:00
|
|
|
when nil, "state"
|
2019-11-22 09:08:31 +00:00
|
|
|
if Utils::Analytics.disabled?
|
|
|
|
puts "Analytics are disabled."
|
2016-05-01 22:04:46 +08:00
|
|
|
else
|
2019-11-22 09:08:31 +00:00
|
|
|
puts "Analytics are enabled."
|
|
|
|
puts "UUID: #{Utils::Analytics.uuid}" if Utils::Analytics.uuid.present?
|
2016-05-01 22:04:46 +08:00
|
|
|
end
|
|
|
|
when "on"
|
2019-11-22 09:08:31 +00:00
|
|
|
Utils::Analytics.enable!
|
2016-05-01 22:04:46 +08:00
|
|
|
when "off"
|
2019-11-22 09:08:31 +00:00
|
|
|
Utils::Analytics.disable!
|
2016-05-01 22:04:46 +08:00
|
|
|
when "regenerate-uuid"
|
2019-11-22 09:08:31 +00:00
|
|
|
Utils::Analytics.regenerate_uuid!
|
2016-05-01 22:04:46 +08:00
|
|
|
else
|
2020-03-04 17:28:15 +00:00
|
|
|
raise UsageError, "unknown subcommand"
|
2016-05-01 22:04:46 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|