# frozen_string_literal: true require "cli/parser" module Homebrew module_function def cat_args Homebrew::CLI::Parser.new do usage_banner <<~EOS `cat` Display the source of . EOS end end def cat 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? raise "`brew cat` doesn't support multiple arguments" if args.remaining.size > 1 cd HOMEBREW_REPOSITORY cat_args = Homebrew.args.options_only - CLI::Parser.global_options.values.map(&:first).flatten safe_system "cat", formulae.first.path, *cat_args end end