mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Add --variations
option to brew info
This commit is contained in:
parent
eab3d077bc
commit
f3e34230ad
@ -219,7 +219,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
alias == eql?
|
alias == eql?
|
||||||
|
|
||||||
def to_hash
|
def to_h
|
||||||
{
|
{
|
||||||
"token" => token,
|
"token" => token,
|
||||||
"full_token" => full_name,
|
"full_token" => full_name,
|
||||||
@ -243,8 +243,8 @@ module Cask
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_h
|
def to_hash_with_variations
|
||||||
hash = to_hash
|
hash = to_h
|
||||||
variations = {}
|
variations = {}
|
||||||
|
|
||||||
hash_keys_to_skip = %w[outdated installed versions]
|
hash_keys_to_skip = %w[outdated installed versions]
|
||||||
@ -260,7 +260,7 @@ module Cask
|
|||||||
|
|
||||||
refresh
|
refresh
|
||||||
|
|
||||||
to_hash.each do |key, value|
|
to_h.each do |key, value|
|
||||||
next if hash_keys_to_skip.include? key
|
next if hash_keys_to_skip.include? key
|
||||||
next if value.to_s == hash[key].to_s
|
next if value.to_s == hash[key].to_s
|
||||||
|
|
||||||
|
@ -61,6 +61,9 @@ module Homebrew
|
|||||||
switch "--all",
|
switch "--all",
|
||||||
depends_on: "--json",
|
depends_on: "--json",
|
||||||
description: "Print JSON of all available formulae."
|
description: "Print JSON of all available formulae."
|
||||||
|
switch "--variations",
|
||||||
|
depends_on: "--json",
|
||||||
|
description: "Include the variations hash in each formula's JSON output."
|
||||||
switch "-v", "--verbose",
|
switch "-v", "--verbose",
|
||||||
description: "Show more verbose analytics data for <formula>."
|
description: "Show more verbose analytics data for <formula>."
|
||||||
switch "--formula", "--formulae",
|
switch "--formula", "--formulae",
|
||||||
@ -202,6 +205,8 @@ module Homebrew
|
|||||||
|
|
||||||
if args.bottle?
|
if args.bottle?
|
||||||
formulae.map(&:to_recursive_bottle_hash)
|
formulae.map(&:to_recursive_bottle_hash)
|
||||||
|
elsif args.variations?
|
||||||
|
formulae.map(&:to_hash_with_variations)
|
||||||
else
|
else
|
||||||
formulae.map(&:to_hash)
|
formulae.map(&:to_hash)
|
||||||
end
|
end
|
||||||
@ -216,6 +221,12 @@ module Homebrew
|
|||||||
|
|
||||||
if args.bottle?
|
if args.bottle?
|
||||||
{ "formulae" => formulae.map(&:to_recursive_bottle_hash) }
|
{ "formulae" => formulae.map(&:to_recursive_bottle_hash) }
|
||||||
|
elsif args.variations?
|
||||||
|
opoo "a"
|
||||||
|
{
|
||||||
|
"formulae" => formulae.map(&:to_hash_with_variations),
|
||||||
|
"casks" => casks.map(&:to_hash_with_variations),
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
"formulae" => formulae.map(&:to_hash),
|
"formulae" => formulae.map(&:to_hash),
|
||||||
|
@ -1909,7 +1909,7 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def to_hash_without_variations
|
def to_hash
|
||||||
dependencies = deps
|
dependencies = deps
|
||||||
|
|
||||||
hsh = {
|
hsh = {
|
||||||
@ -2006,15 +2006,15 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def to_hash
|
def to_hash_with_variations
|
||||||
hash = to_hash_without_variations
|
hash = to_hash
|
||||||
variations = {}
|
variations = {}
|
||||||
|
|
||||||
os_versions = [*MacOSVersions::SYMBOLS.keys, :linux]
|
os_versions = [*MacOSVersions::SYMBOLS.keys, :linux]
|
||||||
|
|
||||||
if path.exist? && self.class.on_system_blocks_exist?
|
if path.exist? && self.class.on_system_blocks_exist?
|
||||||
formula_contents = path.read
|
formula_contents = path.read
|
||||||
[:arm64, :x86_64].each do |arch|
|
[:arm, :intel].each do |arch|
|
||||||
os_versions.each do |os_name|
|
os_versions.each do |os_name|
|
||||||
bottle_tag = Utils::Bottles::Tag.new(system: os_name, arch: arch)
|
bottle_tag = Utils::Bottles::Tag.new(system: os_name, arch: arch)
|
||||||
next unless bottle_tag.valid_combination?
|
next unless bottle_tag.valid_combination?
|
||||||
@ -2028,7 +2028,7 @@ class Formula
|
|||||||
variations_formula = variations_formula_class.new(name, path, :stable,
|
variations_formula = variations_formula_class.new(name, path, :stable,
|
||||||
alias_path: alias_path, force_bottle: force_bottle)
|
alias_path: alias_path, force_bottle: force_bottle)
|
||||||
|
|
||||||
variations_formula.to_hash_without_variations.each do |key, value|
|
variations_formula.to_hash.each do |key, value|
|
||||||
next if value.to_s == hash[key].to_s
|
next if value.to_s == hash[key].to_s
|
||||||
|
|
||||||
variations[bottle_tag.to_sym] ||= {}
|
variations[bottle_tag.to_sym] ||= {}
|
||||||
|
@ -49,6 +49,7 @@ class Formula
|
|||||||
def env; end
|
def env; end
|
||||||
def conflicts; end
|
def conflicts; end
|
||||||
|
|
||||||
|
def self.on_system_blocks_exist?; end
|
||||||
# This method is included by `OnSystem`
|
# This method is included by `OnSystem`
|
||||||
def self.on_macos(&block); end
|
def self.on_macos(&block); end
|
||||||
end
|
end
|
||||||
|
@ -169,6 +169,7 @@ module Utils
|
|||||||
[system, arch].hash
|
[system, arch].hash
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(Symbol) }
|
||||||
def standardized_arch
|
def standardized_arch
|
||||||
return :x86_64 if [:x86_64, :intel].include? arch
|
return :x86_64 if [:x86_64, :intel].include? arch
|
||||||
return :arm64 if [:arm64, :arm].include? arch
|
return :arm64 if [:arm64, :arm].include? arch
|
||||||
|
@ -312,6 +312,7 @@ _brew_abv() {
|
|||||||
--installed
|
--installed
|
||||||
--json
|
--json
|
||||||
--quiet
|
--quiet
|
||||||
|
--variations
|
||||||
--verbose
|
--verbose
|
||||||
"
|
"
|
||||||
return
|
return
|
||||||
@ -1044,6 +1045,7 @@ _brew_info() {
|
|||||||
--installed
|
--installed
|
||||||
--json
|
--json
|
||||||
--quiet
|
--quiet
|
||||||
|
--variations
|
||||||
--verbose
|
--verbose
|
||||||
"
|
"
|
||||||
return
|
return
|
||||||
|
@ -307,6 +307,7 @@ __fish_brew_complete_arg 'abv' -l help -d 'Show this message'
|
|||||||
__fish_brew_complete_arg 'abv' -l installed -d 'Print JSON of formulae that are currently installed'
|
__fish_brew_complete_arg 'abv' -l installed -d 'Print JSON of formulae that are currently installed'
|
||||||
__fish_brew_complete_arg 'abv' -l json -d 'Print a JSON representation. Currently the default value for version is `v1` for formula. For formula and cask use `v2`. See the docs for examples of using the JSON output: https://docs.brew.sh/Querying-Brew'
|
__fish_brew_complete_arg 'abv' -l json -d 'Print a JSON representation. Currently the default value for version is `v1` for formula. For formula and cask use `v2`. See the docs for examples of using the JSON output: https://docs.brew.sh/Querying-Brew'
|
||||||
__fish_brew_complete_arg 'abv' -l quiet -d 'Make some output more quiet'
|
__fish_brew_complete_arg 'abv' -l quiet -d 'Make some output more quiet'
|
||||||
|
__fish_brew_complete_arg 'abv' -l variations -d 'Include the variations hash in each formula\'s JSON output'
|
||||||
__fish_brew_complete_arg 'abv' -l verbose -d 'Show more verbose analytics data for formula'
|
__fish_brew_complete_arg 'abv' -l verbose -d 'Show more verbose analytics data for formula'
|
||||||
__fish_brew_complete_arg 'abv; and not __fish_seen_argument -l cask -l casks' -a '(__fish_brew_suggest_formulae_all)'
|
__fish_brew_complete_arg 'abv; and not __fish_seen_argument -l cask -l casks' -a '(__fish_brew_suggest_formulae_all)'
|
||||||
__fish_brew_complete_arg 'abv; and not __fish_seen_argument -l formula -l formulae' -a '(__fish_brew_suggest_casks_all)'
|
__fish_brew_complete_arg 'abv; and not __fish_seen_argument -l formula -l formulae' -a '(__fish_brew_suggest_casks_all)'
|
||||||
@ -757,6 +758,7 @@ __fish_brew_complete_arg 'info' -l help -d 'Show this message'
|
|||||||
__fish_brew_complete_arg 'info' -l installed -d 'Print JSON of formulae that are currently installed'
|
__fish_brew_complete_arg 'info' -l installed -d 'Print JSON of formulae that are currently installed'
|
||||||
__fish_brew_complete_arg 'info' -l json -d 'Print a JSON representation. Currently the default value for version is `v1` for formula. For formula and cask use `v2`. See the docs for examples of using the JSON output: https://docs.brew.sh/Querying-Brew'
|
__fish_brew_complete_arg 'info' -l json -d 'Print a JSON representation. Currently the default value for version is `v1` for formula. For formula and cask use `v2`. See the docs for examples of using the JSON output: https://docs.brew.sh/Querying-Brew'
|
||||||
__fish_brew_complete_arg 'info' -l quiet -d 'Make some output more quiet'
|
__fish_brew_complete_arg 'info' -l quiet -d 'Make some output more quiet'
|
||||||
|
__fish_brew_complete_arg 'info' -l variations -d 'Include the variations hash in each formula\'s JSON output'
|
||||||
__fish_brew_complete_arg 'info' -l verbose -d 'Show more verbose analytics data for formula'
|
__fish_brew_complete_arg 'info' -l verbose -d 'Show more verbose analytics data for formula'
|
||||||
__fish_brew_complete_arg 'info; and not __fish_seen_argument -l cask -l casks' -a '(__fish_brew_suggest_formulae_all)'
|
__fish_brew_complete_arg 'info; and not __fish_seen_argument -l cask -l casks' -a '(__fish_brew_suggest_formulae_all)'
|
||||||
__fish_brew_complete_arg 'info; and not __fish_seen_argument -l formula -l formulae' -a '(__fish_brew_suggest_casks_all)'
|
__fish_brew_complete_arg 'info; and not __fish_seen_argument -l formula -l formulae' -a '(__fish_brew_suggest_casks_all)'
|
||||||
|
@ -382,6 +382,7 @@ _brew_abv() {
|
|||||||
'(--all)--installed[Print JSON of formulae that are currently installed]' \
|
'(--all)--installed[Print JSON of formulae that are currently installed]' \
|
||||||
'--json[Print a JSON representation. Currently the default value for version is `v1` for formula. For formula and cask use `v2`. See the docs for examples of using the JSON output: https://docs.brew.sh/Querying-Brew]' \
|
'--json[Print a JSON representation. Currently the default value for version is `v1` for formula. For formula and cask use `v2`. See the docs for examples of using the JSON output: https://docs.brew.sh/Querying-Brew]' \
|
||||||
'--quiet[Make some output more quiet]' \
|
'--quiet[Make some output more quiet]' \
|
||||||
|
'--variations[Include the variations hash in each formula'\''s JSON output]' \
|
||||||
'--verbose[Show more verbose analytics data for formula]' \
|
'--verbose[Show more verbose analytics data for formula]' \
|
||||||
- formula \
|
- formula \
|
||||||
'(--cask)--formula[Treat all named arguments as formulae]' \
|
'(--cask)--formula[Treat all named arguments as formulae]' \
|
||||||
@ -931,6 +932,7 @@ _brew_info() {
|
|||||||
'(--all)--installed[Print JSON of formulae that are currently installed]' \
|
'(--all)--installed[Print JSON of formulae that are currently installed]' \
|
||||||
'--json[Print a JSON representation. Currently the default value for version is `v1` for formula. For formula and cask use `v2`. See the docs for examples of using the JSON output: https://docs.brew.sh/Querying-Brew]' \
|
'--json[Print a JSON representation. Currently the default value for version is `v1` for formula. For formula and cask use `v2`. See the docs for examples of using the JSON output: https://docs.brew.sh/Querying-Brew]' \
|
||||||
'--quiet[Make some output more quiet]' \
|
'--quiet[Make some output more quiet]' \
|
||||||
|
'--variations[Include the variations hash in each formula'\''s JSON output]' \
|
||||||
'--verbose[Show more verbose analytics data for formula]' \
|
'--verbose[Show more verbose analytics data for formula]' \
|
||||||
- formula \
|
- formula \
|
||||||
'(--cask)--formula[Treat all named arguments as formulae]' \
|
'(--cask)--formula[Treat all named arguments as formulae]' \
|
||||||
|
@ -295,6 +295,8 @@ If a *`formula`* or *`cask`* is provided, show summary of information about it.
|
|||||||
Print JSON of formulae that are currently installed.
|
Print JSON of formulae that are currently installed.
|
||||||
* `--all`:
|
* `--all`:
|
||||||
Print JSON of all available formulae.
|
Print JSON of all available formulae.
|
||||||
|
* `--variations`:
|
||||||
|
Include the variations hash in each formula's JSON output.
|
||||||
* `-v`, `--verbose`:
|
* `-v`, `--verbose`:
|
||||||
Show more verbose analytics data for *`formula`*.
|
Show more verbose analytics data for *`formula`*.
|
||||||
* `--formula`:
|
* `--formula`:
|
||||||
|
@ -385,6 +385,10 @@ Print JSON of formulae that are currently installed\.
|
|||||||
Print JSON of all available formulae\.
|
Print JSON of all available formulae\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-\-variations\fR
|
||||||
|
Include the variations hash in each formula\'s JSON output\.
|
||||||
|
.
|
||||||
|
.TP
|
||||||
\fB\-v\fR, \fB\-\-verbose\fR
|
\fB\-v\fR, \fB\-\-verbose\fR
|
||||||
Show more verbose analytics data for \fIformula\fR\.
|
Show more verbose analytics data for \fIformula\fR\.
|
||||||
.
|
.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user