29 lines
699 B
Ruby
Raw Normal View History

2019-04-17 18:25:08 +09:00
require "cli/parser"
2019-01-18 22:17:46 +05:30
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
def cat
2019-01-18 22:17:46 +05:30
cat_args.parse
# 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.
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
cd HOMEBREW_REPOSITORY
safe_system "cat", formulae.first.path, *ARGV.options_only
end
end