brew/Library/Homebrew/cmd/leaves.rb

27 lines
556 B
Ruby
Raw Normal View History

2016-04-08 16:28:43 +02:00
#: * `leaves`:
#: Show installed formulae that are not dependencies of another installed formula.
require "formula"
require "tab"
module Homebrew
2016-09-26 01:44:51 +02:00
module_function
def leaves
installed = Formula.installed.sort
2018-03-25 12:43:04 +01:00
deps_of_installed = installed.flat_map do |f|
f.runtime_dependencies.map do |dep|
begin
dep.to_formula.full_name
rescue FormulaUnavailableError
dep.name
end
end
end
2018-03-25 12:43:04 +01:00
leaves = installed.map(&:full_name) - deps_of_installed
leaves.each(&method(:puts))
end
end