Merge pull request #5566 from GauthamGoli/analytics-args
analytics: Use CLI::Parser to parse args
This commit is contained in:
commit
8c8eec1b1e
@ -8,15 +8,35 @@
|
|||||||
#: * `analytics` `regenerate-uuid`:
|
#: * `analytics` `regenerate-uuid`:
|
||||||
#: Regenerate UUID used in Homebrew's analytics.
|
#: Regenerate UUID used in Homebrew's analytics.
|
||||||
|
|
||||||
|
require "cli_parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
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 <https://docs.brew.sh/Analytics>.
|
||||||
|
|
||||||
|
If `regenerate-uuid` is passed, regenerate UUID used in Homebrew's analytics.
|
||||||
|
EOS
|
||||||
|
switch :verbose
|
||||||
|
switch :debug
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def analytics
|
def analytics
|
||||||
|
analytics_args.parse
|
||||||
config_file = HOMEBREW_REPOSITORY/".git/config"
|
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"
|
when nil, "state"
|
||||||
analyticsdisabled =
|
analyticsdisabled =
|
||||||
Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsdisabled").chomp
|
Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsdisabled").chomp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user