Skip to content
Snippets Groups Projects
Commit cf961caa authored by William Ma's avatar William Ma
Browse files

caskroom: Add --caskroom command

parent 36c10edf
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
# 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
# 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
--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
......
.\" 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
......
.\" 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\.
.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment