29 lines
692 B
Ruby
Raw Normal View History

2019-01-18 22:17:46 +05:30
require "cli_parser"
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>
Display the source to <formula>.
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
exec "cat", formulae.first.path, *ARGV.options_only
end
end