Class: Homebrew::Cmd::Bundle Private

Inherits:
AbstractCommand show all
Extended by:
Utils::Output::Mixin
Defined in:
cmd/bundle.rb,
bundle/subcommand.rb,
bundle/subcommand/sh.rb,
bundle/subcommand/add.rb,
bundle/subcommand/env.rb,
bundle/subcommand/dump.rb,
bundle/subcommand/edit.rb,
bundle/subcommand/exec.rb,
bundle/subcommand/list.rb,
bundle/subcommand/check.rb,
bundle/subcommand/remove.rb,
bundle/subcommand/cleanup.rb,
bundle/subcommand/install.rb,
bundle/subcommand_context.rb,
sorbet/rbi/dsl/homebrew/cmd/bundle.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: AddSubcommand, Args, CheckSubcommand, CleanupSubcommand, DumpSubcommand, EditSubcommand, EnvSubcommand, ExecSubcommand, InstallSubcommand, ListSubcommand, RemoveSubcommand, ShSubcommand, SubcommandContext

Constant Summary collapse

BUNDLE_EXTENSIONS =

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

T.let(Homebrew::Bundle.extensions.dup.freeze, T::Array[T.class_of(Homebrew::Bundle::Extension)])
BUNDLE_SOURCES_DESCRIPTION =

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

T.let(
  [
    "Homebrew",
    "Homebrew Cask",
    *BUNDLE_EXTENSIONS.map(&:banner_name),
  ].to_sentence.freeze,
  String,
)

Class Method Summary collapse

Instance Method Summary collapse

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

Methods inherited from AbstractCommand

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

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Class Method Details

.context(args, extensions:, ask: false) ⇒ SubcommandContext

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.

Parameters:

Returns:



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
# File 'bundle/subcommand.rb', line 64

def context(args, extensions:, ask: false)
  subcommand = T.let(args.subcommand || "install", String)
  jobs_arg = args.jobs || Homebrew::EnvConfig.bundle_jobs
  jobs = if jobs_arg == "auto"
    [Etc.nprocessors, 4].min
  else
    jobs_arg&.to_i || 1
  end
  no_upgrade = if args.upgrade?
    false
  else
    args.no_upgrade?.present?
  end

  SubcommandContext.new(
    subcommand:,
    global:       args.global?,
    file:         args.file,
    no_upgrade:,
    verbose:      args.verbose?,
    force:        args.force?,
    ask:,
    jobs:         [jobs, 1].max,
    zap:          args.zap?,
    no_type_args: no_type_args?(args, extensions:),
    extensions:,
  )
end

.dispatch(args, extensions:) ⇒ void

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.

Parameters:

Raises:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'bundle/subcommand.rb', line 28

def dispatch(args, extensions:)
  ask = Homebrew::EnvConfig.ask?

  # Don't want to ask for input in Bundle
  ENV["HOMEBREW_ASK"] = nil

  if !args.describe? && (dump_describe = ENV["HOMEBREW_BUNDLE_DUMP_DESCRIBE"].presence)
    opoo "`HOMEBREW_BUNDLE_DUMP_DESCRIBE` is deprecated. Use `HOMEBREW_BUNDLE_DESCRIBE` instead."
    # odeprecated "HOMEBREW_BUNDLE_DUMP_DESCRIBE", "HOMEBREW_BUNDLE_DESCRIBE"
    ENV["HOMEBREW_BUNDLE_DESCRIBE"] = dump_describe
  end

  context = context(args, extensions:, ask:)
  Homebrew::Bundle.upgrade_formulae = args.upgrade_formulae

  if args.install?
    redirect_stdout($stderr) do
      InstallSubcommand.new(args, context:, quiet: true, cleanup: false).run
    end
  end

  subcommand_class = Homebrew::AbstractSubcommand.subcommands_for(Homebrew::Cmd::Bundle).find do |candidate|
    candidate.subcommand_name == context.subcommand
  end
  raise UsageError, "Unknown subcommand: #{context.subcommand}" unless subcommand_class

  subcommand_class.new(args, context:).run
end

.no_type_args?(args, extensions:) ⇒ Boolean

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.

Parameters:

Returns:

  • (Boolean)


99
100
101
102
# File 'bundle/subcommand.rb', line 99

def no_type_args?(args, extensions:)
  ([args.formulae?, args.casks?, args.taps?] +
    extensions.map { |extension| args.public_send(extension.predicate_method) }).none?
end

Instance Method Details

#argsHomebrew::Cmd::Bundle::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/bundle.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.



61
62
63
64
65
66
# File 'cmd/bundle.rb', line 61

def run
  # Keep this inside `run` to keep --help fast.
  require "bundle"

  Homebrew::Cmd::Bundle.dispatch(args, extensions: BUNDLE_EXTENSIONS)
end