| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2020-03-04 17:28:15 +00:00
										 |  |  |       named :formula | 
					
						
							| 
									
										
										
										
											2019-01-18 22:17:46 +05:30
										 |  |  |     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
										 |  |  | 
 | 
					
						
							|  |  |  |     cd HOMEBREW_REPOSITORY | 
					
						
							| 
									
										
										
										
											2020-04-05 15:44:50 +01:00
										 |  |  |     pager = if Homebrew::EnvConfig.bat? | 
					
						
							| 
									
										
										
										
											2020-05-02 18:21:36 +01:00
										 |  |  |       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-04-14 14:21:17 +01:00
										 |  |  |     safe_system pager, args.formulae_paths.first, *args.passthrough | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | end |