caskroom: Add --caskroom command
This commit is contained in:
parent
36c10edf22
commit
cf961caa27
@ -35,6 +35,7 @@ module Homebrew
|
||||
@resolved_formulae_casks = nil
|
||||
@formulae_paths = nil
|
||||
@casks = nil
|
||||
@loaded_casks = nil
|
||||
@kegs = nil
|
||||
@kegs_casks = nil
|
||||
|
||||
@ -125,6 +126,10 @@ module Homebrew
|
||||
.freeze
|
||||
end
|
||||
|
||||
def loaded_casks
|
||||
@loaded_casks ||= downcased_unique_named.map(&Cask::CaskLoader.method(:load)).freeze
|
||||
end
|
||||
|
||||
def kegs
|
||||
@kegs ||= downcased_unique_named.map do |name|
|
||||
resolve_keg name
|
||||
|
||||
30
Library/Homebrew/cmd/--caskroom.rb
Normal file
30
Library/Homebrew/cmd/--caskroom.rb
Normal file
@ -0,0 +1,30 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
|
||||
def __caskroom_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
usage_banner <<~EOS
|
||||
`--caskroom` [<cask>]
|
||||
|
||||
Display Homebrew's Caskroom path.
|
||||
|
||||
If <cask> is provided, display the location in the Caskroom where <cask>
|
||||
would be installed, without any sort of versioned directory as the last path.
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
def __caskroom
|
||||
args = __caskroom_args.parse
|
||||
|
||||
if args.loaded_casks.blank?
|
||||
puts Cask::Caskroom.path
|
||||
else
|
||||
args.loaded_casks.each do |cask|
|
||||
puts "#{Cask::Caskroom.path}/#{cask.token}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
26
Library/Homebrew/test/cmd/--caskroom_spec.rb
Normal file
26
Library/Homebrew/test/cmd/--caskroom_spec.rb
Normal file
@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe "brew --caskroom", :integration_test do
|
||||
let(:local_transmission) {
|
||||
Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||
}
|
||||
|
||||
let(:local_caffeine) {
|
||||
Cask::CaskLoader.load(cask_path("local-caffeine"))
|
||||
}
|
||||
|
||||
it "outputs Homebrew's caskroom" do
|
||||
expect { brew "--caskroom" }
|
||||
.to output("#{HOMEBREW_PREFIX/"Caskroom"}\n").to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "outputs the caskroom path of casks" do
|
||||
expect { brew "--caskroom", cask_path("local-transmission"), cask_path("local-caffeine") }
|
||||
.to output("#{HOMEBREW_PREFIX/"Caskroom"/"local-transmission"}\n" \
|
||||
"#{HOMEBREW_PREFIX/"Caskroom"/"local-caffeine\n"}").to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
end
|
||||
@ -1,4 +1,5 @@
|
||||
--cache
|
||||
--caskroom
|
||||
--cellar
|
||||
--config
|
||||
--env
|
||||
|
||||
@ -610,6 +610,13 @@ If *`formula`* is provided, display the file or directory used to cache *`formul
|
||||
* `--cask`:
|
||||
Only show cache files for casks.
|
||||
|
||||
### `--caskroom` [*`cask`*]
|
||||
|
||||
Display Homebrew's Caskroom path.
|
||||
|
||||
If *`cask`* is provided, display the location in the Caskroom where *`cask`* would
|
||||
be installed, without any sort of versioned directory as the last path.
|
||||
|
||||
### `--cellar` [*`formula`*]
|
||||
|
||||
Display Homebrew's Cellar path. *Default:* `$(brew --prefix)/Cellar`, or if that
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "BREW\-CASK" "1" "July 2020" "Homebrew" "brew-cask"
|
||||
.TH "BREW\-CASK" "1" "August 2020" "Homebrew" "brew-cask"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBbrew\-cask\fR \- a friendly binary installer for macOS
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "BREW" "1" "July 2020" "Homebrew" "brew"
|
||||
.TH "BREW" "1" "August 2020" "Homebrew" "brew"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBbrew\fR \- The Missing Package Manager for macOS
|
||||
@ -807,6 +807,12 @@ Only show cache files for formulae\.
|
||||
\fB\-\-cask\fR
|
||||
Only show cache files for casks\.
|
||||
.
|
||||
.SS "\fB\-\-caskroom\fR [\fIcask\fR]"
|
||||
Display Homebrew\'s Caskroom path\.
|
||||
.
|
||||
.P
|
||||
If \fIcask\fR is provided, display the location in the Caskroom where \fIcask\fR would be installed, without any sort of versioned directory as the last path\.
|
||||
.
|
||||
.SS "\fB\-\-cellar\fR [\fIformula\fR]"
|
||||
Display Homebrew\'s Cellar path\. \fIDefault:\fR \fB$(brew \-\-prefix)/Cellar\fR, or if that directory doesn\'t exist, \fB$(brew \-\-repository)/Cellar\fR\.
|
||||
.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user