Class: Homebrew::Cmd::Cache

Inherits:
AbstractCommand show all
Includes:
Fetch
Defined in:
cmd/--cache.rb

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Fetch

#fetch_bottle?

Methods inherited from AbstractCommand

command, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Class Method Details

.command_nameString

Returns:



14
# File 'cmd/--cache.rb', line 14

def self.command_name = "--cache"

Instance Method Details

#runvoid

This method returns an undefined value.



50
51
52
53
54
55
56
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
# File 'cmd/--cache.rb', line 50

def run
  if args.no_named?
    puts HOMEBREW_CACHE
    return
  end

  formulae_or_casks = args.named.to_formulae_and_casks
  os_arch_combinations = args.os_arch_combinations

  formulae_or_casks.each do |formula_or_cask|
    case formula_or_cask
    when Formula
      formula = formula_or_cask
      ref = formula.loaded_from_api? ? formula.full_name : formula.path

      os_arch_combinations.each do |os, arch|
        SimulateSystem.with(os:, arch:) do
          formula = Formulary.factory(ref)
          print_formula_cache(formula, os:, arch:)
        end
      end
    when Cask::Cask
      cask = formula_or_cask
      ref = cask.loaded_from_api? ? cask.full_name : cask.sourcefile_path

      os_arch_combinations.each do |os, arch|
        next if os == :linux

        SimulateSystem.with(os:, arch:) do
          loaded_cask = Cask::CaskLoader.load(ref)
          print_cask_cache(loaded_cask)
        end
      end
    else
      raise "Invalid type: #{formula_or_cask.class}"
    end
  end
end