Class: Teapot::Command::Fetch

Inherits:
Samovar::Command
  • Object
show all
Defined in:
lib/teapot/command/fetch.rb

Instance Method Summary collapse

Instance Method Details

#invoke(parent) ⇒ Object



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
88
# File 'lib/teapot/command/fetch.rb', line 51

def invoke(parent)
  logger = parent.logger
  context = parent.context
  
  updated = Set.new
  selection = context.select
  
  packages = selection.configuration.packages
  
  if @packages.any?
    packages = packages.slice(@packages)
  end
  
  # If no additional packages were resolved, we have reached a fixed point:
  while packages.any?
    packages.each do |package|
      fetch_package(context, selection.configuration, package, logger, **@options)
    end
    
    selection = context.select
    
    # If there are no unresolved packages, we are done.
    if selection.unresolved.empty?
      break
    end
    
    packages = selection.unresolved
  end

  if selection.unresolved.count > 0
    logger.error "Could not fetch all packages!".color(:red)
    selection.unresolved.each do |package|
      logger.error "\t#{package}".color(:red)
    end
  else
    logger.info "Completed fetch successfully.".color(:green)
  end
end