info: support analytics for cask-install
This commit is contained in:
parent
fbb28175d8
commit
705f03ef9f
@ -26,7 +26,7 @@ module Homebrew
|
|||||||
flag "--category",
|
flag "--category",
|
||||||
depends_on: "--analytics",
|
depends_on: "--analytics",
|
||||||
description: "The value for `category` must be `install`, `install-on-request`, "\
|
description: "The value for `category` must be `install`, `install-on-request`, "\
|
||||||
"`build-error` or `os-version`. The default is `install`."
|
"`cask-install`, `build-error` or `os-version`. The default is `install`."
|
||||||
switch "--github",
|
switch "--github",
|
||||||
description: "Open a browser to the GitHub History page for provided <formula>. "\
|
description: "Open a browser to the GitHub History page for provided <formula>. "\
|
||||||
"To view formula history locally: `brew log -p` <formula>"
|
"To view formula history locally: `brew log -p` <formula>"
|
||||||
@ -223,7 +223,7 @@ module Homebrew
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def analytics_table(category, days, results, os_version: false)
|
def analytics_table(category, days, results, os_version: false, cask_install: false)
|
||||||
oh1 "#{category} (#{days} days)"
|
oh1 "#{category} (#{days} days)"
|
||||||
total_count = results.values.inject("+")
|
total_count = results.values.inject("+")
|
||||||
formatted_total_count = format_count(total_count)
|
formatted_total_count = format_count(total_count)
|
||||||
@ -234,6 +234,8 @@ module Homebrew
|
|||||||
percent_header = "Percent"
|
percent_header = "Percent"
|
||||||
name_with_options_header = if os_version
|
name_with_options_header = if os_version
|
||||||
"macOS Version"
|
"macOS Version"
|
||||||
|
elsif cask_install
|
||||||
|
"Token"
|
||||||
else
|
else
|
||||||
"Name (with options)"
|
"Name (with options)"
|
||||||
end
|
end
|
||||||
@ -314,7 +316,7 @@ module Homebrew
|
|||||||
raise UsageError, "days must be one of #{valid_days.join(", ")}" unless valid_days.include?(days)
|
raise UsageError, "days must be one of #{valid_days.join(", ")}" unless valid_days.include?(days)
|
||||||
|
|
||||||
category = args.category || "install"
|
category = args.category || "install"
|
||||||
valid_categories = %w[install install-on-request build-error os-version]
|
valid_categories = %w[install install-on-request cask-install build-error os-version]
|
||||||
unless valid_categories.include?(category)
|
unless valid_categories.include?(category)
|
||||||
raise UsageError, "category must be one of #{valid_categories.join(", ")}"
|
raise UsageError, "category must be one of #{valid_categories.join(", ")}"
|
||||||
end
|
end
|
||||||
@ -323,10 +325,13 @@ module Homebrew
|
|||||||
return if json.blank? || json["items"].blank?
|
return if json.blank? || json["items"].blank?
|
||||||
|
|
||||||
os_version = category == "os-version"
|
os_version = category == "os-version"
|
||||||
|
cask_install = category == "cask-install"
|
||||||
results = {}
|
results = {}
|
||||||
json["items"].each do |item|
|
json["items"].each do |item|
|
||||||
key = if os_version
|
key = if os_version
|
||||||
item["os_version"]
|
item["os_version"]
|
||||||
|
elsif cask_install
|
||||||
|
item["cask"]
|
||||||
else
|
else
|
||||||
item["formula"]
|
item["formula"]
|
||||||
end
|
end
|
||||||
@ -341,7 +346,7 @@ module Homebrew
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
analytics_table(category, days, results, os_version: os_version)
|
analytics_table(category, days, results, os_version: os_version, cask_install: cask_install)
|
||||||
end
|
end
|
||||||
|
|
||||||
def output_formula_analytics(f)
|
def output_formula_analytics(f)
|
||||||
|
@ -203,7 +203,7 @@ Display brief statistics for your Homebrew installation.
|
|||||||
* `--days`:
|
* `--days`:
|
||||||
The value for `days` must be `30`, `90` or `365`. The default is `30`.
|
The value for `days` must be `30`, `90` or `365`. The default is `30`.
|
||||||
* `--category`:
|
* `--category`:
|
||||||
The value for `category` must be `install`, `install-on-request`, `build-error` or `os-version`. The default is `install`.
|
The value for `category` must be `install`, `install-on-request`, `cask-install`, `build-error` or `os-version`. The default is `install`.
|
||||||
* `--github`:
|
* `--github`:
|
||||||
Open a browser to the GitHub History page for provided *`formula`*. To view formula history locally: `brew log -p` *`formula`*
|
Open a browser to the GitHub History page for provided *`formula`*. To view formula history locally: `brew log -p` *`formula`*
|
||||||
* `--json`:
|
* `--json`:
|
||||||
|
@ -243,7 +243,7 @@ The value for \fBdays\fR must be \fB30\fR, \fB90\fR or \fB365\fR\. The default i
|
|||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-category\fR
|
\fB\-\-category\fR
|
||||||
The value for \fBcategory\fR must be \fBinstall\fR, \fBinstall\-on\-request\fR, \fBbuild\-error\fR or \fBos\-version\fR\. The default is \fBinstall\fR\.
|
The value for \fBcategory\fR must be \fBinstall\fR, \fBinstall\-on\-request\fR, \fBcask\-install\fR, \fBbuild\-error\fR or \fBos\-version\fR\. The default is \fBinstall\fR\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-github\fR
|
\fB\-\-github\fR
|
||||||
|
Loading…
x
Reference in New Issue
Block a user