brew/Library/Homebrew/cmd/leaves.rb
Issy Long 341ea60807
Auto-fix Style/RedundantBegin offenses
- This also required auto-fixes for Layout/EmptyLinesAroundBlockBody and
  Layout/InconsistentIndentation once the auto-fixer had got rid of the
  "redundant begin"s.
2019-10-13 16:04:27 +01:00

38 lines
724 B
Ruby

# frozen_string_literal: true
require "formula"
require "tab"
require "cli/parser"
module Homebrew
module_function
def leaves_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`leaves`
List installed formulae that are not dependencies of another installed formula.
EOS
switch :debug
end
end
def leaves
leaves_args.parse
installed = Formula.installed.sort
deps_of_installed = installed.flat_map do |f|
f.runtime_dependencies.map do |dep|
dep.to_formula.full_name
rescue FormulaUnavailableError
dep.name
end
end
leaves = installed.map(&:full_name) - deps_of_installed
leaves.each(&method(:puts))
end
end