Port Homebrew::Cmd::Analytics
This commit is contained in:
parent
02a0ea8449
commit
3cedf33150
@ -1,14 +1,13 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "abstract_command"
|
||||
require "cli/parser"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
|
||||
sig { returns(CLI::Parser) }
|
||||
def analytics_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
module Cmd
|
||||
class Analytics < AbstractCommand
|
||||
cmd_args do
|
||||
description <<~EOS
|
||||
Control Homebrew's anonymous aggregate user behaviour analytics.
|
||||
Read more at <https://docs.brew.sh/Analytics>.
|
||||
@ -22,12 +21,9 @@ module Homebrew
|
||||
|
||||
named_args %w[state on off regenerate-uuid], max: 1
|
||||
end
|
||||
end
|
||||
|
||||
sig { void }
|
||||
def analytics
|
||||
args = analytics_args.parse
|
||||
|
||||
sig { override.void }
|
||||
def run
|
||||
case args.named.first
|
||||
when nil, "state"
|
||||
if Utils::Analytics.disabled?
|
||||
@ -49,3 +45,5 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/analytics"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
RSpec.describe "brew analytics" do
|
||||
RSpec.describe Homebrew::Cmd::Analytics do
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
it "when HOMEBREW_NO_ANALYTICS is unset is disabled after running `brew analytics off`", :integration_test do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user