32 lines
568 B
Ruby
Raw Normal View History

# frozen_string_literal: true
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
named :formula
2019-01-18 22:17:46 +05:30
end
end
def cat
2020-07-30 18:40:10 +02:00
args = cat_args.parse
cd HOMEBREW_REPOSITORY
2020-04-05 15:44:50 +01:00
pager = if Homebrew::EnvConfig.bat?
ENV["BAT_CONFIG_PATH"] = Homebrew::EnvConfig.bat_config_path
2019-09-30 15:40:20 +02:00
"#{HOMEBREW_PREFIX}/bin/bat"
2020-04-05 15:44:50 +01:00
else
"cat"
2019-09-30 15:40:20 +02:00
end
2020-07-30 18:40:10 +02:00
safe_system pager, args.formulae_paths.first
end
end