Class: Homebrew::Cmd::Uses Private

Inherits:
AbstractCommand show all
Includes:
DependenciesHelpers
Defined in:
cmd/uses.rb,
sorbet/rbi/dsl/homebrew/cmd/uses.rbi

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

brew uses foo bar returns formulae that use both foo and bar If you want the union, run the command twice and concatenate the results. The intersection is harder to achieve with shell tools.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods included from DependenciesHelpers

#args_includes_ignores, dependents, #recursive_includes, #select_includes

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::Cmd::Uses::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



10
# File 'sorbet/rbi/dsl/homebrew/cmd/uses.rbi', line 10

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'cmd/uses.rb', line 57

def run
  Formulary.enable_factory_cache!

  used_formulae_missing = false
  used_formulae = begin
    args.named.to_formulae
  rescue FormulaUnavailableError => e
    opoo e
    used_formulae_missing = true
    # If the formula doesn't exist: fake the needed formula object name.
    # This is a legacy use of OpenStruct that should be refactored.
    # rubocop:disable Style/OpenStructUse
    args.named.map { |name| OpenStruct.new name:, full_name: name }
    # rubocop:enable Style/OpenStructUse
  end

  use_runtime_dependents = args.installed? &&
                           !used_formulae_missing &&
                           !args.include_build? &&
                           !args.include_test? &&
                           !args.include_optional? &&
                           !args.skip_recommended?

  uses = intersection_of_dependents(use_runtime_dependents, used_formulae)

  return if uses.empty?

  puts Formatter.columns(uses.map(&:full_name).sort)
  odie "Missing formulae should not have dependents!" if used_formulae_missing
end