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

51 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require "fetch"
2019-04-17 18:25:08 +09:00
require "cli/parser"
require "cask/cmd"
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",
2019-04-30 08:44:35 +01:00
description: "Show the cache file used when building from source."
2019-01-30 21:29:21 +00:00
switch "--force-bottle",
2019-04-30 08:44:35 +01:00
description: "Show the cache file used when pouring a bottle."
2019-01-30 21:29:21 +00:00
conflicts "--build-from-source", "--force-bottle"
end
end
def __cache
2019-01-30 21:29:21 +00:00
__cache_args.parse
if args.no_named?
puts HOMEBREW_CACHE
else
args.formulae_and_casks.each do |formula_or_cask|
case formula_or_cask
when Formula
formula = formula_or_cask
if Fetch.fetch_bottle?(formula)
puts formula.bottle.cached_download
else
puts formula.cached_download
end
when Cask::Cask
cask = formula_or_cask
puts "cask: #{Cask::Cmd::Cache.cached_location(cask)}"
end
end
end
end
end