From 169ac2d413d1a354e1a273759fac61faa2357c17 Mon Sep 17 00:00:00 2001 From: Cheng XU Date: Thu, 23 May 2019 15:20:24 +0800 Subject: [PATCH] cask: add new --cache command It prints the file used to cache Casks. This can be used to help users to install casks with their files downloaded from outside brew. See #6157. --- Library/Homebrew/cask/cmd.rb | 1 + Library/Homebrew/cask/cmd/--cache.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Library/Homebrew/cask/cmd/--cache.rb diff --git a/Library/Homebrew/cask/cmd.rb b/Library/Homebrew/cask/cmd.rb index efb5566fa3..d69687900f 100644 --- a/Library/Homebrew/cask/cmd.rb +++ b/Library/Homebrew/cask/cmd.rb @@ -10,6 +10,7 @@ require "cask/config" require "cask/cmd/options" require "cask/cmd/abstract_command" +require "cask/cmd/--cache" require "cask/cmd/audit" require "cask/cmd/automerge" require "cask/cmd/cat" diff --git a/Library/Homebrew/cask/cmd/--cache.rb b/Library/Homebrew/cask/cmd/--cache.rb new file mode 100644 index 0000000000..d3aaf8e027 --- /dev/null +++ b/Library/Homebrew/cask/cmd/--cache.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require "cask/download" + +module Cask + class Cmd + class Cache < AbstractCommand + def self.command_name + "--cache" + end + + def initialize(*) + super + raise CaskUnspecifiedError if args.empty? + end + + def run + casks.each do |cask| + puts Download.new(cask).downloader.cached_location + end + end + + def self.help + "display the file used to cache the Cask" + end + end + end +end