New command 'brew deps [formula]'
Where brew info will show the next-level-down dependencies, brew deps will show all of the formulae that a given formula depends on.
This commit is contained in:
parent
56f82a33b1
commit
7366a41268
@ -38,10 +38,25 @@ class Formulary
|
||||
# Returns all formula names as strings, with or without aliases
|
||||
def self.names with_aliases=false
|
||||
everything = (HOMEBREW_REPOSITORY+'Library/Formula').children.map{|f| f.basename('.rb').to_s }
|
||||
everything.push *Formulary.get_aliases.keys if with_aliases
|
||||
if with_aliases
|
||||
everything.push *Formulary.get_aliases.keys
|
||||
end
|
||||
everything.sort
|
||||
end
|
||||
|
||||
def self.read name
|
||||
Formulary.names.each do |f|
|
||||
next if f != name
|
||||
|
||||
require Formula.path(name)
|
||||
klass_name = Formula.class_s(name)
|
||||
klass = eval(klass_name)
|
||||
return klass
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
# Loads all formula classes.
|
||||
def self.read_all
|
||||
Formulary.names.each do |name|
|
||||
|
||||
29
bin/brew
29
bin/brew
@ -246,6 +246,35 @@ begin
|
||||
puts "#{name} is a dependency for #{our_deps.join(', ')}."
|
||||
end
|
||||
end
|
||||
|
||||
when 'deps'
|
||||
require 'formula'
|
||||
|
||||
ARGV.formulae.each do |f|
|
||||
name = f.name
|
||||
|
||||
our_deps = []
|
||||
checked = {}
|
||||
to_check = [name]
|
||||
|
||||
while ! to_check.empty?
|
||||
item = to_check.pop
|
||||
checked[item] = true
|
||||
|
||||
formula = Formulary.read item
|
||||
next if formula == nil || formula.deps == nil || formula.deps.empty?
|
||||
|
||||
our_deps.push(*formula.deps)
|
||||
to_check.push(*formula.deps.select{|g| !checked[g]})
|
||||
end
|
||||
|
||||
if our_deps.empty?
|
||||
puts "#{name} has no dependencies."
|
||||
else
|
||||
our_deps.sort!
|
||||
puts "#{name} depends on #{our_deps.join(", ")}"
|
||||
end
|
||||
end
|
||||
|
||||
when 'pull', 'push', 'checkout', 'branch'
|
||||
onoe "Unknown command: #{arg} (did you mean 'git #{arg}'?)"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user