Class: Guac::Commands::Up

Inherits:
Object
  • Object
show all
Defined in:
lib/guac/commands/up.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, args = []) ⇒ Up

Returns a new instance of Up.



8
9
10
11
# File 'lib/guac/commands/up.rb', line 8

def initialize(options, args = [])
  @options = options
  @repos = Guac::Repo.build_from_config(args[1])
end

Instance Method Details

#execute(_input: $stdin, output: $stdout) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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