brew/Library/Homebrew/cmd/--cache.rb

40 lines
944 B
Ruby
Raw Normal View History

require "fetch"
2019-04-17 18:25:08 +09:00
require "cli/parser"
module Homebrew
2016-09-26 01:44:51 +02:00
module_function
2019-01-30 21:29:21 +00:00
def __cache_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`--cache` [<options>] [<formula>]
Display Homebrew's download cache. See also `HOMEBREW_CACHE`.
If <formula> is provided, display the file or directory used to cache <formula>.
EOS
switch "-s", "--build-from-source",
description: "Show the cache file used when building from source."
switch "--force-bottle",
description: "Show the cache file used when pouring a bottle."
conflicts "--build-from-source", "--force-bottle"
end
end
def __cache
2019-01-30 21:29:21 +00:00
__cache_args.parse
if ARGV.named.empty?
puts HOMEBREW_CACHE
else
ARGV.formulae.each do |f|
if Fetch.fetch_bottle?(f)
puts f.bottle.cached_download
else
puts f.cached_download
end
end
end
end
end