| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  | require 'formula' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # `brew uses foo bar` now returns formula that use both foo and bar | 
					
						
							|  |  |  | # Rationale: If you want the union just run the command twice and | 
					
						
							|  |  |  | # concatenate the results. | 
					
						
							|  |  |  | # The intersection is harder to achieve with shell tools. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module Homebrew extend self | 
					
						
							|  |  |  |   def uses | 
					
						
							| 
									
										
										
										
											2012-02-04 00:01:29 -06:00
										 |  |  |     raise FormulaUnspecifiedError if ARGV.named.empty? | 
					
						
							| 
									
										
										
										
											2012-01-29 21:42:09 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-21 11:39:45 -04:00
										 |  |  |     uses = Formula.select do |f| | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |       ARGV.formulae.all? do |ff| | 
					
						
							| 
									
										
										
										
											2012-03-16 22:00:59 -07:00
										 |  |  |         if ARGV.flag? '--recursive' | 
					
						
							| 
									
										
										
										
											2013-01-23 00:26:29 -06:00
										 |  |  |           f.recursive_dependencies.any? { |dep| dep.name == ff.name } | 
					
						
							| 
									
										
										
										
											2012-03-16 22:00:59 -07:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2013-01-23 00:26:29 -06:00
										 |  |  |           f.deps.any? { |dep| dep.name == ff.name } | 
					
						
							| 
									
										
										
										
											2012-03-16 22:00:59 -07:00
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2012-01-29 21:42:09 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |     if ARGV.include? "--installed" | 
					
						
							| 
									
										
										
										
											2013-01-23 00:26:29 -06:00
										 |  |  |       uses = uses.select { |f| Formula.installed.include? f } | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2012-01-29 21:42:09 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-23 00:26:29 -06:00
										 |  |  |     puts_columns uses.map(&:to_s).sort | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | end |