brew/Library/Homebrew/cmd/leaves.rb

32 lines
631 B
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: false
# frozen_string_literal: true
require "formula"
require "tab"
2019-04-17 18:25:08 +09:00
require "cli/parser"
module Homebrew
2016-09-26 01:44:51 +02:00
module_function
2018-11-11 19:13:28 +05:30
def leaves_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`leaves`
List installed formulae that are not dependencies of another installed formula.
2018-11-11 19:13:28 +05:30
EOS
2020-07-30 18:40:10 +02:00
max_named 0
2018-11-11 19:13:28 +05:30
end
end
def leaves
2018-11-11 19:13:28 +05:30
leaves_args.parse
installed = Formula.installed.sort
deps_of_installed = installed.flat_map(&:runtime_formula_dependencies)
leaves = installed.map(&:full_name) - deps_of_installed.map(&:full_name)
2018-03-25 12:43:04 +01:00
leaves.each(&method(:puts))
end
end