2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-04-17 18:25:08 +09:00
|
|
|
require "cli/parser"
|
2019-01-18 22:17:46 +05:30
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2016-09-26 01:44:51 +02:00
|
|
|
module_function
|
|
|
|
|
2019-01-18 22:17:46 +05:30
|
|
|
def cat_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
|
|
|
usage_banner <<~EOS
|
|
|
|
`cat` <formula>
|
|
|
|
|
2019-01-31 20:33:16 +01:00
|
|
|
Display the source of <formula>.
|
2019-01-18 22:17:46 +05:30
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
def cat
|
2019-01-18 22:17:46 +05:30
|
|
|
cat_args.parse
|
2010-09-11 20:22:54 +01:00
|
|
|
# do not "fix" this to support multiple arguments, the output would be
|
|
|
|
# unparsable, if the user wants to cat multiple formula they can call
|
|
|
|
# brew cat multiple times.
|
2015-10-25 01:13:16 +01:00
|
|
|
formulae = ARGV.formulae
|
|
|
|
raise FormulaUnspecifiedError if formulae.empty?
|
2019-01-18 22:17:46 +05:30
|
|
|
raise "`brew cat` doesn't support multiple arguments" if args.remaining.size > 1
|
2010-09-11 20:22:54 +01:00
|
|
|
|
|
|
|
cd HOMEBREW_REPOSITORY
|
2019-09-29 18:01:38 +02:00
|
|
|
pager = ENV["HOMEBREW_VISUAL"] || "cat"
|
|
|
|
safe_system pager, formulae.first.path, *Homebrew.args.passthrough
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
end
|