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

32 lines
673 B
Ruby
Raw Normal View History

2019-04-17 18:25:08 +09:00
require "cli/parser"
module Homebrew
2016-09-26 01:44:51 +02:00
module_function
2019-01-30 21:29:43 +00:00
def __prefix_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`--prefix` [<formula>]
Display Homebrew's install path. *Default:* `/usr/local` on macOS and
`/home/linuxbrew/.linuxbrew` on Linux.
If <formula> is provided, display the location in the cellar where <formula>
is or would be installed.
EOS
end
end
def __prefix
2019-01-30 21:29:43 +00:00
__prefix_args.parse
if ARGV.named.empty?
puts HOMEBREW_PREFIX
else
puts ARGV.resolved_formulae.map { |f|
f.opt_prefix.exist? ? f.opt_prefix : f.installed_prefix
}
end
end
end