Class: Homebrew::Cmd::Bundle::InstallSubcommand Private

Inherits:
AbstractSubcommand show all
Defined in:
bundle/subcommand/install.rb

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.

Instance Attribute Summary

Attributes inherited from AbstractSubcommand

#args, #cleanup, #context, #quiet, #targets

Instance Method Summary collapse

Methods inherited from AbstractSubcommand

define, define_all, #initialize, subcommand_name, subcommands_for

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #pretty_upgradable

Constructor Details

This class inherits a constructor from Homebrew::AbstractSubcommand

Instance Method Details

#dslHomebrew::Bundle::Dsl?

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.

Returns:



104
105
106
107
# File 'bundle/subcommand/install.rb', line 104

def dsl
  @dsl ||= T.let(nil, T.nilable(Homebrew::Bundle::Dsl))
  @dsl
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'bundle/subcommand/install.rb', line 57

def run
  if args.zap? && !args.cleanup? && !args.force_cleanup?
    raise UsageError, "`--zap` cannot be passed without `--cleanup` or `--force-cleanup`."
  end

  if args.cleanup? && !context.force && !args.force_cleanup? && !context.ask
    raise UsageError, "`brew bundle install --cleanup` requires `--force`, `--force-cleanup` " \
                      "or `$HOMEBREW_ASK`."
  end
  # odeprecated "HOMEBREW_BUNDLE_INSTALL_CLEANUP", "HOMEBREW_BUNDLE_FORCE_INSTALL_CLEANUP"

  @dsl = Homebrew::Bundle::Brewfile.read(global: context.global, file: context.file)
  result = Homebrew::Bundle::Installer.install!(
    @dsl.entries,
    global:     context.global,
    file:       context.file,
    no_lock:    false,
    no_upgrade: context.no_upgrade,
    verbose:    context.verbose,
    force:      context.force,
    jobs:       context.jobs,
    quiet:      quiet || args.quiet?,
  )

  # Mark Brewfile formulae as installed_on_request to prevent autoremove
  # from removing them when their dependents are uninstalled
  Homebrew::Bundle.mark_as_installed_on_request!(@dsl.entries)

  result || exit(1)

  return unless cleanup

  cleanup_requested = args.force_cleanup? || args.cleanup?
  return unless cleanup_requested

  require "bundle/subcommand/cleanup"

  # Don't need to reset cleanup specifically but this resets all the dumper modules.
  Homebrew::Cmd::Bundle::CleanupSubcommand.reset!
  Homebrew::Cmd::Bundle::CleanupSubcommand.cleanup(
    global: context.global, file: context.file, zap: context.zap,
    force: context.force || args.force_cleanup?,
    ask: context.ask, dsl:
  )
end