diff --git a/Library/Homebrew/cmd/analytics.rb b/Library/Homebrew/cmd/analytics.rb index 60ebb03da9..9aeb179d0e 100644 --- a/Library/Homebrew/cmd/analytics.rb +++ b/Library/Homebrew/cmd/analytics.rb @@ -8,15 +8,35 @@ #: * `analytics` `regenerate-uuid`: #: Regenerate UUID used in Homebrew's analytics. +require "cli_parser" + module Homebrew module_function + def analytics_args + Homebrew::CLI::Parser.new do + usage_banner <<~EOS + `analytics` (`on`|`off`) [`state`] [`regenerate-uuid`] + + If `on`|`off` is passed, turn Homebrew's analytics on or off respectively. + + If `state` is passed, display anonymous user behaviour analytics state. + Read more at . + + If `regenerate-uuid` is passed, regenerate UUID used in Homebrew's analytics. + EOS + switch :verbose + switch :debug + end + end + def analytics + analytics_args.parse config_file = HOMEBREW_REPOSITORY/".git/config" - raise UsageError if ARGV.named.size > 1 + raise UsageError if args.remaining.size > 1 - case ARGV.named.first + case args.remaining.first when nil, "state" analyticsdisabled = Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsdisabled").chomp