Class: Homebrew::Cmd::Deps Private

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

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.

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::Deps::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/deps.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.

Raises:



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'cmd/deps.rb', line 88

def run
  raise UsageError, "`brew deps --os=all` is not supported" if args.os == "all"
  raise UsageError, "`brew deps --arch=all` is not supported" if args.arch == "all"

  os, arch = T.must(args.os_arch_combinations.first)
  all = args.eval_all?

  Formulary.enable_factory_cache!

  SimulateSystem.with(os:, arch:) do
    recursive = !args.direct?
    installed = args.installed? || dependents(args.named.to_formulae_and_casks).all?(&:any_version_installed?)

    @use_runtime_dependencies = installed && recursive &&
                                !args.tree? &&
                                !args.graph? &&
                                !args.HEAD? &&
                                !args.include_build? &&
                                !args.include_test? &&
                                !args.include_optional? &&
                                !args.skip_recommended? &&
                                !args.missing? &&
                                args.os.nil? &&
                                args.arch.nil?

    if args.tree? || args.graph?
      dependents = if args.named.present?
        sorted_dependents(args.named.to_formulae_and_casks)
      elsif args.installed?
        case args.only_formula_or_cask
        when :formula
          sorted_dependents(Formula.installed)
        when :cask
          sorted_dependents(Cask::Caskroom.casks)
        else
          sorted_dependents(Formula.installed + Cask::Caskroom.casks)
        end
      else
        raise FormulaUnspecifiedError
      end

      if args.graph?
        dot_code = dot_code(dependents, recursive:)
        if args.dot?
          puts dot_code
        else
          exec_browser "https://dreampuf.github.io/GraphvizOnline/##{ERB::Util.url_encode(dot_code)}"
        end
        return
      end

      puts_deps_tree(dependents, recursive:)
      return
    elsif all
      puts_deps(sorted_dependents(
                  Formula.all(eval_all: args.eval_all?) + Cask::Cask.all(eval_all: args.eval_all?),
                ), recursive:)
      return
    elsif !args.no_named? && args.for_each?
      puts_deps(sorted_dependents(args.named.to_formulae_and_casks), recursive:)
      return
    end

    if args.no_named?
      raise FormulaUnspecifiedError unless args.installed?

      sorted_dependents_formulae_and_casks = case args.only_formula_or_cask
      when :formula
        sorted_dependents(Formula.installed)
      when :cask
        sorted_dependents(Cask::Caskroom.casks)
      else
        sorted_dependents(Formula.installed + Cask::Caskroom.casks)
      end
      puts_deps(sorted_dependents_formulae_and_casks, recursive:)
      return
    end

    dependents = dependents(args.named.to_formulae_and_casks)
    check_head_spec(dependents) if args.HEAD?

    all_deps = deps_for_dependents(dependents, recursive:, &(args.union? ? :| : :&))
    condense_requirements(all_deps)
    all_deps.map! { |d| dep_display_name(d) }
    all_deps.uniq!
    all_deps.sort! unless args.topological?
    puts all_deps
  end
end