brew deps foo bar now gives the dependency intersection
Rationale: this is more useful than the union, and you can still easily get the union by running the command twice and concatenating the result.
This commit is contained in:
parent
521f1ec959
commit
e96744eb6f
@ -1,14 +1,24 @@
|
|||||||
|
require 'formula'
|
||||||
|
|
||||||
module Homebrew extend self
|
module Homebrew extend self
|
||||||
def deps
|
def deps
|
||||||
puts if ARGV.include?('--all')
|
if ARGV.include? '--all'
|
||||||
require 'formula'
|
Formula.each do |f|
|
||||||
Formula.all.each do |f|
|
# TODO add a space after the colon??
|
||||||
"#{f.name}:#{f.deps.join(' ')}"
|
puts "#{f.name}:#{f.deps*' '}"
|
||||||
end
|
end
|
||||||
elsif ARGV.include?("-1") or ARGV.include?("--1")
|
|
||||||
*ARGV.formulae.map{ |f| f.deps or [] }.flatten.uniq.sort
|
|
||||||
else
|
else
|
||||||
*ARGV.formulae.map{ |f| f.recursive_deps.map{ |f| f.name } }.flatten.uniq.sort
|
func = if ARGV.one? then :deps else :recursive_deps end
|
||||||
|
puts ARGV.formulae.map(&func).intersection.sort
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Array
|
||||||
|
def intersection
|
||||||
|
a = []
|
||||||
|
each{ |b| a |= b }
|
||||||
|
each{ |c| a &= c }
|
||||||
|
a
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -54,6 +54,9 @@ module HomebrewArgvExtension
|
|||||||
def build_head?
|
def build_head?
|
||||||
flag? '--HEAD'
|
flag? '--HEAD'
|
||||||
end
|
end
|
||||||
|
def one?
|
||||||
|
flag? "--1"
|
||||||
|
end
|
||||||
|
|
||||||
def flag? flag
|
def flag? flag
|
||||||
options_only.each do |arg|
|
options_only.each do |arg|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user