Class: Homebrew::Cmd::Bundle::SubcommandContext Private

Inherits:
T::Struct
  • Object
show all
Defined in:
bundle/subcommand_context.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 collapse

Instance Method Summary collapse

Constructor Details

#initialize(subcommand:, global:, file: nil, no_upgrade:, verbose:, force:, ask:, zap:, no_type_args:, extensions:) ⇒ void

Parameters:

  • subcommand (String)
  • global (Boolean)
  • file (String, nil) (defaults to: nil)
  • no_upgrade (Boolean)
  • verbose (Boolean)
  • force (Boolean)
  • ask (Boolean)
  • zap (Boolean)
  • no_type_args (Boolean)
  • extensions (Array<T.class_of(Homebrew::Bundle::Extension)>)


# File ''

const :subcommand, String
const :global, T::Boolean
const :file, T.nilable(String)
const :no_upgrade, T::Boolean
const :verbose, T::Boolean
const :force, T::Boolean
const :ask, T::Boolean
const :zap, T::Boolean
const :no_type_args, T::Boolean
const :extensions, T::Array[T.class_of(Homebrew::Bundle::Extension)]

Instance Attribute Details

#askBoolean (readonly)

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 the value of prop ask.

Returns:

  • (Boolean)


# File ''

const :ask, T::Boolean

#extensionsArray<T.class_of(Homebrew::Bundle::Extension)> (readonly)

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 the value of prop extensions.

Returns:



# File ''

const :extensions, T::Array[T.class_of(Homebrew::Bundle::Extension)]

#fileString? (readonly)

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 the value of prop file.

Returns:



# File ''

const :file, T.nilable(String)

#forceBoolean (readonly)

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 the value of prop force.

Returns:

  • (Boolean)


# File ''

const :force, T::Boolean

#globalBoolean (readonly)

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 the value of prop global.

Returns:

  • (Boolean)


# File ''

const :global, T::Boolean

#no_type_argsBoolean (readonly)

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 the value of prop no_type_args.

Returns:

  • (Boolean)


# File ''

const :no_type_args, T::Boolean

#no_upgradeBoolean (readonly)

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 the value of prop no_upgrade.

Returns:

  • (Boolean)


# File ''

const :no_upgrade, T::Boolean

#subcommandString (readonly)

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 the value of prop subcommand.

Returns:



# File ''

const :subcommand, String

#verboseBoolean (readonly)

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 the value of prop verbose.

Returns:

  • (Boolean)


# File ''

const :verbose, T::Boolean

#zapBoolean (readonly)

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 the value of prop zap.

Returns:

  • (Boolean)


# File ''

const :zap, T::Boolean

Instance Method Details

#core_type_options(args, prefix, all: false) ⇒ Hash{Symbol => 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:

  • args (T.untyped)
  • prefix (String)
  • all (Boolean) (defaults to: false)

Returns:



43
44
45
46
47
48
49
# File 'bundle/subcommand_context.rb', line 43

def core_type_options(args, prefix, all: false)
  {
    formulae: type_selected?(args, :formulae?, :no_formulae?, :"no_#{prefix}_brew?", all:),
    casks:    type_selected?(args, :casks?, :no_casks?, :"no_#{prefix}_cask?", all:),
    taps:     type_selected?(args, :taps?, :no_taps?, :"no_#{prefix}_tap?", all:),
  }
end

#extension_disabled?(args, extension) ⇒ 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)


34
35
36
37
# File 'bundle/subcommand_context.rb', line 34

def extension_disabled?(args, extension)
  args.public_send(extension.disable_predicate_method) ||
    args.public_send(:"no_cleanup_#{extension.type}?")
end

#extension_dump_disabled?(args, extension) ⇒ 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)


28
29
30
31
# File 'bundle/subcommand_context.rb', line 28

def extension_dump_disabled?(args, extension)
  args.public_send(extension.dump_disable_predicate_method) ||
    args.public_send(:"no_dump_#{extension.type}?")
end

#extension_selected?(args, extension) ⇒ 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)


23
24
25
# File 'bundle/subcommand_context.rb', line 23

def extension_selected?(args, extension)
  args.public_send(extension.predicate_method)
end

#selected_types(args) ⇒ Array<Symbol>

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:

  • args (T.untyped)

Returns:



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'bundle/subcommand_context.rb', line 52

def selected_types(args)
  # We intentionally omit the s from `brews`, `casks`, and `taps` for ease of handling later.
  type_hash = {
    brew: args.formulae?,
    cask: args.casks?,
    tap:  args.taps?,
  }
  extensions.each do |extension|
    type_hash[extension.type] = extension_selected?(args, extension)
  end
  type_hash[:none] = no_type_args
  type_hash.select { |_, v| v }.keys
end