Merge pull request #6163 from xu-cheng/cask-cache
Add brew cask --cache <cask> command
This commit is contained in:
commit
781ad57ded
@ -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"
|
||||
|
||||
28
Library/Homebrew/cask/cmd/--cache.rb
Normal file
28
Library/Homebrew/cask/cmd/--cache.rb
Normal file
@ -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
|
||||
@ -21,6 +21,9 @@ graphical user interface.
|
||||
|
||||
## COMMANDS
|
||||
|
||||
* `--cache` <token> [ <token> ... ]:
|
||||
Display the file used to cache the Cask identified by <token>.
|
||||
|
||||
* `audit` [--language=<iso-language>[,<iso-language> ... ]] [ <token> ... ]:
|
||||
Check the given Casks for installability.
|
||||
If no tokens are given on the command line, all Casks are audited.
|
||||
|
||||
38
Library/Homebrew/test/cask/cmd/cache_spec.rb
Normal file
38
Library/Homebrew/test/cask/cmd/cache_spec.rb
Normal file
@ -0,0 +1,38 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative "shared_examples/requires_cask_token"
|
||||
require_relative "shared_examples/invalid_option"
|
||||
|
||||
describe Cask::Cmd::Cache, :cask do
|
||||
let(:local_transmission) {
|
||||
Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||
}
|
||||
|
||||
let(:local_caffeine) {
|
||||
Cask::CaskLoader.load(cask_path("local-caffeine"))
|
||||
}
|
||||
|
||||
it_behaves_like "a command that requires a Cask token"
|
||||
it_behaves_like "a command that handles invalid options"
|
||||
|
||||
it "prints the file used to cache the Cask" do
|
||||
transmission_location = CurlDownloadStrategy.new(
|
||||
local_transmission.url.to_s, local_transmission.token, local_transmission.version,
|
||||
cache: Cask::Cache.path, **local_transmission.url.specs
|
||||
).cached_location
|
||||
caffeine_location = CurlDownloadStrategy.new(
|
||||
local_caffeine.url.to_s, local_caffeine.token, local_caffeine.version,
|
||||
cache: Cask::Cache.path, **local_caffeine.url.specs
|
||||
).cached_location
|
||||
|
||||
expect do
|
||||
described_class.run("local-transmission", "local-caffeine")
|
||||
end.to output("#{transmission_location}\n#{caffeine_location}\n").to_stdout
|
||||
end
|
||||
|
||||
it "properly handles Casks that are not present" do
|
||||
expect {
|
||||
described_class.run("notacask")
|
||||
}.to raise_error(Cask::CaskUnavailableError)
|
||||
end
|
||||
end
|
||||
@ -25,6 +25,10 @@ Uninstall Cask identified by \fItoken\fR\.
|
||||
.SH "COMMANDS"
|
||||
.
|
||||
.TP
|
||||
\fB\-\-cache\fR \fItoken\fR [ \fItoken\fR \.\.\. ]
|
||||
Display the file used to cache the Cask identified by \fItoken\fR\.
|
||||
.
|
||||
.TP
|
||||
\fBaudit\fR [\-\-language=\fIiso\-language\fR[,\fIiso\-language\fR \.\.\. ]] [ \fItoken\fR \.\.\. ]
|
||||
Check the given Casks for installability\. If no tokens are given on the command line, all Casks are audited\.
|
||||
.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user