| 
									
										
										
										
											2020-11-25 17:03:23 +01:00
										 |  |  | # typed: true | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-07 23:25:02 -08:00
										 |  |  | require "formula" | 
					
						
							| 
									
										
										
										
											2019-04-17 18:25:08 +09:00
										 |  |  | require "cli/parser" | 
					
						
							| 
									
										
										
										
											2017-02-07 23:25:02 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | module Homebrew | 
					
						
							|  |  |  |   module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |   sig { returns(CLI::Parser) } | 
					
						
							| 
									
										
										
										
											2018-07-30 18:25:38 +05:30
										 |  |  |   def formula_args | 
					
						
							|  |  |  |     Homebrew::CLI::Parser.new do | 
					
						
							| 
									
										
										
										
											2021-01-15 15:04:02 -05:00
										 |  |  |       description <<~EOS | 
					
						
							| 
									
										
										
										
											2019-08-06 14:20:27 -04:00
										 |  |  |         Display the path where <formula> is located. | 
					
						
							| 
									
										
										
										
											2018-09-28 21:39:52 +05:30
										 |  |  |       EOS | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-22 16:53:46 +01:00
										 |  |  |       named_args :formula, min: 1, without_api: true | 
					
						
							| 
									
										
										
										
											2018-04-01 16:47:30 +05:30
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-07-30 18:25:38 +05:30
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def formula | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  |     args = formula_args.parse | 
					
						
							| 
									
										
										
										
											2018-04-01 16:47:30 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-13 10:27:12 -06:00
										 |  |  |     formula_paths = args.named.to_paths(only: :formula).select(&:exist?) | 
					
						
							|  |  |  |     if formula_paths.blank? && args.named | 
					
						
							|  |  |  |                                    .to_paths(only: :cask) | 
					
						
							|  |  |  |                                    .select(&:exist?) | 
					
						
							|  |  |  |                                    .present? | 
					
						
							|  |  |  |       odie "Found casks but did not find formulae!" | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     formula_paths.each(&method(:puts)) | 
					
						
							| 
									
										
										
										
											2017-02-07 23:25:02 -08:00
										 |  |  |   end | 
					
						
							|  |  |  | end |