postinstall.rb 697 Bytes
Newer Older
Markus Reiter's avatar
Markus Reiter committed
1
# typed: true
2
3
# frozen_string_literal: true

Xu Cheng's avatar
Xu Cheng committed
4
require "sandbox"
5
require "formula_installer"
6
require "cli/parser"
Xu Cheng's avatar
Xu Cheng committed
7

8
module Homebrew
Markus Reiter's avatar
Markus Reiter committed
9
10
  extend T::Sig

11
12
  module_function

Markus Reiter's avatar
Markus Reiter committed
13
  sig { returns(CLI::Parser) }
14
15
16
17
18
19
20
  def postinstall_args
    Homebrew::CLI::Parser.new do
      usage_banner <<~EOS
        `postinstall` <formula>

        Rerun the post-install steps for <formula>.
      EOS
Markus Reiter's avatar
Markus Reiter committed
21

22
      min_named :keg
23
24
25
    end
  end

26
  def postinstall
27
    args = postinstall_args.parse
28

29
    args.named.to_resolved_formulae.each do |f|
30
      ohai "Postinstalling #{f}"
Markus Reiter's avatar
Markus Reiter committed
31
      fi = FormulaInstaller.new(f, **{ debug: args.debug?, quiet: args.quiet?, verbose: args.verbose? }.compact)
32
      fi.post_install
Xu Cheng's avatar
Xu Cheng committed
33
    end
34
35
  end
end