class Guac::Commands::Up

Public Class Methods

new(options, args = []) click to toggle source
# File lib/guac/commands/up.rb, line 8
def initialize(options, args = [])
  @options = options
  @repos = Guac::Repo.build_from_config(args[1])
end

Public Instance Methods

execute(_input: $stdin, output: $stdout) click to toggle source
# File lib/guac/commands/up.rb, line 13
def execute(_input: $stdin, output: $stdout)
  threads = @repos.map do |repo|
    output.puts "Updating #{repo.name.bold} on branch #{repo.branch.underline}".blue

    Thread.new do
      response = []

      begin
        repo.checkout
        response << repo.pull
      rescue Guac::SysCommandError => e
        response << repo.dir.bold.red
        response << e.message.red
      end

      response.compact!
      response = Colors.paint(response)
      response.unshift(repo.name.bold.blue)
      response.join("\n")
    end
  end

  output.puts "\n"
  output.puts threads.map(&:value)
end