Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e9f09adde2 | |||
| d8521a0fc7 | |||
| 379092b344 |
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
require "formula"
|
require "formula"
|
||||||
require "json"
|
require "json"
|
||||||
|
require "readall"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module Cmd
|
||||||
|
class BrewerTapContentInfo < AbstractCommand
|
||||||
def brewer_tap_content_info_args
|
cmd_args do
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Do something. Place a description here.
|
Display the information about third-party casks and formulas.
|
||||||
EOS
|
EOS
|
||||||
flag "--json",
|
flag "--json",
|
||||||
description: "Print a JSON representation. Currently the default value for <version> is `v1` for " \
|
description: "Print a JSON representation. Currently the default value for <version> is `v1` for " \
|
||||||
@@ -20,19 +20,19 @@ module Homebrew
|
|||||||
switch "--cask", "--casks",
|
switch "--cask", "--casks",
|
||||||
description: "Treat all named arguments as casks."
|
description: "Treat all named arguments as casks."
|
||||||
conflicts "--formula", "--cask"
|
conflicts "--formula", "--cask"
|
||||||
|
|
||||||
named_args [:tap]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def brewer_tap_content_info
|
def run
|
||||||
args = brewer_tap_content_info_args.parse
|
begin
|
||||||
|
original_stderr = $stderr.clone
|
||||||
|
$stderr.reopen(File.new("/dev/null", "w"))
|
||||||
|
|
||||||
formulae = []
|
formulae = []
|
||||||
casks = []
|
casks = []
|
||||||
|
|
||||||
Tap.each do |tap|
|
Tap.each do |tap|
|
||||||
next if ["homebrew/core", "homebrew/cask"].include?(tap.name)
|
next if ["homebrew/core", "homebrew/cask"].include?(tap.name)
|
||||||
|
next unless valid_tap? tap
|
||||||
|
|
||||||
unless args.cask?
|
unless args.cask?
|
||||||
tap.formula_files.each do |formula_file|
|
tap.formula_files.each do |formula_file|
|
||||||
@@ -42,7 +42,7 @@ module Homebrew
|
|||||||
|
|
||||||
unless args.formula?
|
unless args.formula?
|
||||||
tap.cask_files.each do |cask_file|
|
tap.cask_files.each do |cask_file|
|
||||||
casks << Cask::CaskLoader::FromTapPathLoader.new(cask_file).load(config: nil)
|
casks << Cask::CaskLoader::FromPathLoader.new(cask_file).load(config: nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -53,5 +53,20 @@ module Homebrew
|
|||||||
}
|
}
|
||||||
|
|
||||||
puts JSON.pretty_generate(json)
|
puts JSON.pretty_generate(json)
|
||||||
|
ensure
|
||||||
|
$stderr.reopen(original_stderr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def valid_tap?(tap)
|
||||||
|
begin
|
||||||
|
Readall.valid_tap?(tap, aliases: true)
|
||||||
|
rescue Interrupt, RuntimeError
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user