Class: Teapot::Command::Status

Inherits:
Selection
  • Object
show all
Defined in:
lib/teapot/command/status.rb

Instance Method Summary collapse

Methods inherited from Selection

#invoke, #selection, #targets

Instance Method Details

#process(selection) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/teapot/command/status.rb', line 38

def process(selection)
  context = selection.context
  terminal = self.terminal
  
  selection.resolved.each do |package|
    repository = Rugged::Repository.new(package.path.to_s)
    
    changes = {}
    repository.status do |file, status|
      unless status == [:ignored]
        changes[file] = status
      end
    end
    
    next if changes.empty?
    
    terminal.puts "Package #{package.name} (from #{package.path}):"
    
    changes.each do |file, statuses|
      terminal.puts "\t#{file} (#{statuses})", style: statuses.last
    end
  end
end

#terminal(output = $stdout) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/teapot/command/status.rb', line 30

def terminal(output = $stdout)
  Console::Terminal.for(output).tap do |terminal|
    terminal[:worktree_new] = terminal.style(:green)
    terminal[:worktree_modified] = terminal.style(:yellow)
    terminal[:worktree_deleted] = terminal.style(:red)
  end
end