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

38 lines
786 B
Ruby
Raw Normal View History

2020-11-25 17:03:23 +01:00
# typed: true
# frozen_string_literal: true
2019-04-17 18:25:08 +09:00
require "cli/parser"
module Homebrew
2020-10-20 12:03:48 +02:00
extend T::Sig
2016-09-26 01:44:51 +02:00
module_function
2020-10-20 12:03:48 +02:00
sig { returns(CLI::Parser) }
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>
2019-01-30 21:29:43 +00:00
is or would be installed.
EOS
end
end
def __prefix
2020-07-30 18:40:10 +02:00
args = __prefix_args.parse
2019-01-30 21:29:43 +00:00
if args.no_named?
puts HOMEBREW_PREFIX
else
puts args.named.to_resolved_formulae.map { |f|
f.opt_prefix.exist? ? f.opt_prefix : f.latest_installed_prefix
}
end
end
end