Merge pull request #5877 from EricFromCanada/info-update-options
info: flag and doc fixes and updates
This commit is contained in:
commit
9cb518aa61
@ -13,37 +13,42 @@ module Homebrew
|
|||||||
def info_args
|
def info_args
|
||||||
Homebrew::CLI::Parser.new do
|
Homebrew::CLI::Parser.new do
|
||||||
usage_banner <<~EOS
|
usage_banner <<~EOS
|
||||||
`info` [<formula>]
|
`info` [<options>] [<formula>]
|
||||||
|
|
||||||
Display brief statistics for your Homebrew installation.
|
Display brief statistics for your Homebrew installation.
|
||||||
|
|
||||||
|
If <formula> is specified, show summary of information about <formula>.
|
||||||
EOS
|
EOS
|
||||||
switch "--analytics",
|
switch "--analytics",
|
||||||
description: "Display Homebrew analytics data (provided neither `HOMEBREW_NO_ANALYTICS` "\
|
description: "Display global Homebrew analytics data or, if specified, installation and "\
|
||||||
"or `HOMEBREW_NO_GITHUB_API` are set)."
|
"build error data for <formula> (provided neither `HOMEBREW_NO_ANALYTICS` "\
|
||||||
|
"nor `HOMEBREW_NO_GITHUB_API` are set)."
|
||||||
flag "--days",
|
flag "--days",
|
||||||
depends_on: "--analytics",
|
depends_on: "--analytics",
|
||||||
description: "The value for `days` must be `30`, `90` or `365`. The default is `30`."
|
description: "How many days of global analytics data to retrieve. "\
|
||||||
|
"The value for <days> must be `30`, `90` or `365`. The default is `30`."
|
||||||
flag "--category",
|
flag "--category",
|
||||||
depends_on: "--analytics",
|
depends_on: "--analytics",
|
||||||
description: "The value for `category` must be `install`, `install-on-request`, "\
|
description: "Which type of global analytics data to retrieve. "\
|
||||||
"`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`."
|
||||||
switch "--github",
|
switch "--github",
|
||||||
description: "Open a browser to the GitHub History page for provided <formula>. "\
|
description: "Open a browser to the GitHub source page for <formula>. "\
|
||||||
"To view formula history locally: `brew log -p` <formula>"
|
"To view formula history locally: `brew log -p` <formula>"
|
||||||
flag "--json",
|
flag "--json",
|
||||||
description: "Print a JSON representation of <formula>. Currently the default and only accepted "\
|
description: "Print a JSON representation of <formula>. Currently the default and only accepted "\
|
||||||
"value for <version> is `v1`. See the docs for examples of using the JSON "\
|
"value for <version> is `v1`. See the docs for examples of using the JSON "\
|
||||||
"output: <https://docs.brew.sh/Querying-Brew>"
|
"output: <https://docs.brew.sh/Querying-Brew>"
|
||||||
switch "--all",
|
|
||||||
depends_on: "--json",
|
|
||||||
description: "Get information on all formulae."
|
|
||||||
switch "--installed",
|
switch "--installed",
|
||||||
depends_on: "--json",
|
depends_on: "--json",
|
||||||
description: "Get information on all installed formulae."
|
description: "Print JSON of formulae that are currently installed."
|
||||||
|
switch "--all",
|
||||||
|
depends_on: "--json",
|
||||||
|
description: "Print JSON of all available formulae."
|
||||||
switch :verbose,
|
switch :verbose,
|
||||||
description: "See more verbose analytics data."
|
description: "Show more verbose analytics data for <formula>."
|
||||||
switch :debug
|
switch :debug
|
||||||
conflicts "--all", "--installed"
|
conflicts "--installed", "--all"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -214,7 +219,7 @@ module Homebrew
|
|||||||
def formulae_api_json(endpoint)
|
def formulae_api_json(endpoint)
|
||||||
return if ENV["HOMEBREW_NO_ANALYTICS"] || ENV["HOMEBREW_NO_GITHUB_API"]
|
return if ENV["HOMEBREW_NO_ANALYTICS"] || ENV["HOMEBREW_NO_GITHUB_API"]
|
||||||
|
|
||||||
output, = curl_output("--max-time", "3",
|
output, = curl_output("--max-time", "5",
|
||||||
"https://formulae.brew.sh/api/#{endpoint}")
|
"https://formulae.brew.sh/api/#{endpoint}")
|
||||||
return if output.blank?
|
return if output.blank?
|
||||||
|
|
||||||
@ -223,7 +228,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 +239,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
|
||||||
@ -311,22 +318,25 @@ module Homebrew
|
|||||||
def output_analytics(filter: nil)
|
def output_analytics(filter: nil)
|
||||||
days = args.days || "30"
|
days = args.days || "30"
|
||||||
valid_days = %w[30 90 365]
|
valid_days = %w[30 90 365]
|
||||||
raise ArgumentError("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 ArgumentError("Categories must be one of #{valid_categories.join(", ")}")
|
raise UsageError, "category must be one of #{valid_categories.join(", ")}"
|
||||||
end
|
end
|
||||||
|
|
||||||
json = formulae_api_json("analytics/#{category}/#{days}d.json")
|
json = formulae_api_json("analytics/#{category}/#{days}d.json")
|
||||||
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 +351,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)
|
||||||
|
|||||||
@ -194,24 +194,26 @@ If no logs are found, an error message is presented.
|
|||||||
Open *`formula`*'s homepage in a browser. If no formula is provided, open
|
Open *`formula`*'s homepage in a browser. If no formula is provided, open
|
||||||
Homebrew's own homepage in a browser.
|
Homebrew's own homepage in a browser.
|
||||||
|
|
||||||
### `info` [*`formula`*]
|
### `info` [*`options`*] [*`formula`*]
|
||||||
|
|
||||||
Display brief statistics for your Homebrew installation.
|
Display brief statistics for your Homebrew installation.
|
||||||
|
|
||||||
|
If *`formula`* is specified, show summary of information about *`formula`*.
|
||||||
|
|
||||||
* `--analytics`:
|
* `--analytics`:
|
||||||
Display Homebrew analytics data (provided neither `HOMEBREW_NO_ANALYTICS` or `HOMEBREW_NO_GITHUB_API` are set).
|
Display global Homebrew analytics data or, if specified, installation and build error data for *`formula`* (provided neither `HOMEBREW_NO_ANALYTICS` nor `HOMEBREW_NO_GITHUB_API` are set).
|
||||||
* `--days`:
|
* `--days`:
|
||||||
The value for `days` must be `30`, `90` or `365`. The default is `30`.
|
How many days of global analytics data to retrieve. 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`.
|
Which type of global analytics data to retrieve. 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 source page for *`formula`*. To view formula history locally: `brew log -p` *`formula`*
|
||||||
* `--json`:
|
* `--json`:
|
||||||
Print a JSON representation of *`formula`*. Currently the default and only accepted value for *`version`* is `v1`. See the docs for examples of using the JSON output: <https://docs.brew.sh/Querying-Brew>
|
Print a JSON representation of *`formula`*. Currently the default and only accepted value for *`version`* is `v1`. See the docs for examples of using the JSON output: <https://docs.brew.sh/Querying-Brew>
|
||||||
* `--all`:
|
|
||||||
Get information on all formulae.
|
|
||||||
* `--installed`:
|
* `--installed`:
|
||||||
Get information on all installed formulae.
|
Print JSON of formulae that are currently installed.
|
||||||
|
* `--all`:
|
||||||
|
Print JSON of all available formulae.
|
||||||
|
|
||||||
### `install` [*`options`*] *`formula`*
|
### `install` [*`options`*] *`formula`*
|
||||||
|
|
||||||
|
|||||||
@ -230,36 +230,39 @@ The Gist will be marked private and will not appear in listings but will be acce
|
|||||||
.SS "\fBhome\fR [\fIformula\fR]"
|
.SS "\fBhome\fR [\fIformula\fR]"
|
||||||
Open \fIformula\fR\'s homepage in a browser\. If no formula is provided, open Homebrew\'s own homepage in a browser\.
|
Open \fIformula\fR\'s homepage in a browser\. If no formula is provided, open Homebrew\'s own homepage in a browser\.
|
||||||
.
|
.
|
||||||
.SS "\fBinfo\fR [\fIformula\fR]"
|
.SS "\fBinfo\fR [\fIoptions\fR] [\fIformula\fR]"
|
||||||
Display brief statistics for your Homebrew installation\.
|
Display brief statistics for your Homebrew installation\.
|
||||||
.
|
.
|
||||||
|
.P
|
||||||
|
If \fIformula\fR is specified, show summary of information about \fIformula\fR\.
|
||||||
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-analytics\fR
|
\fB\-\-analytics\fR
|
||||||
Display Homebrew analytics data (provided neither \fBHOMEBREW_NO_ANALYTICS\fR or \fBHOMEBREW_NO_GITHUB_API\fR are set)\.
|
Display global Homebrew analytics data or, if specified, installation and build error data for \fIformula\fR (provided neither \fBHOMEBREW_NO_ANALYTICS\fR nor \fBHOMEBREW_NO_GITHUB_API\fR are set)\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-days\fR
|
\fB\-\-days\fR
|
||||||
The value for \fBdays\fR must be \fB30\fR, \fB90\fR or \fB365\fR\. The default is \fB30\fR\.
|
How many days of global analytics data to retrieve\. The value for \fIdays\fR must be \fB30\fR, \fB90\fR or \fB365\fR\. The default is \fB30\fR\.
|
||||||
.
|
.
|
||||||
.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\.
|
Which type of global analytics data to retrieve\. The value for \fIcategory\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
|
||||||
Open a browser to the GitHub History page for provided \fIformula\fR\. To view formula history locally: \fBbrew log \-p\fR \fIformula\fR
|
Open a browser to the GitHub source page for \fIformula\fR\. To view formula history locally: \fBbrew log \-p\fR \fIformula\fR
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-json\fR
|
\fB\-\-json\fR
|
||||||
Print a JSON representation of \fIformula\fR\. Currently the default and only accepted value for \fIversion\fR is \fBv1\fR\. See the docs for examples of using the JSON output: \fIhttps://docs\.brew\.sh/Querying\-Brew\fR
|
Print a JSON representation of \fIformula\fR\. Currently the default and only accepted value for \fIversion\fR is \fBv1\fR\. See the docs for examples of using the JSON output: \fIhttps://docs\.brew\.sh/Querying\-Brew\fR
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-all\fR
|
\fB\-\-installed\fR
|
||||||
Get information on all formulae\.
|
Print JSON of formulae that are currently installed\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-installed\fR
|
\fB\-\-all\fR
|
||||||
Get information on all installed formulae\.
|
Print JSON of all available formulae\.
|
||||||
.
|
.
|
||||||
.SS "\fBinstall\fR [\fIoptions\fR] \fIformula\fR"
|
.SS "\fBinstall\fR [\fIoptions\fR] \fIformula\fR"
|
||||||
Install \fIformula\fR\.
|
Install \fIformula\fR\.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user