Class: Teapot::Command::Status

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

Instance Method Summary collapse

Instance Method Details

#invoke(parent) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/teapot/command/status.rb', line 37

def invoke(parent)
	context = parent.context
	logger = parent.logger
	
	context.configuration.packages.each do |package|
		# The root package is the local package for this context:
		next unless only == nil or only.include?(package.name)
		
		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?
		
		logger.info "Package #{package.name} (from #{package.path}):".bright
		
		changes.each do |file, status|
			if status == [:worktree_new]
				logger.info "\t#{file}".color(:blue)
			elsif status == [:worktree_modified]
				logger.info "\t#{file}".color(:orange)
			elsif status == [:worktree_deleted]
				logger.info "\t#{file}".color(:red)
			else
				logger.info "\t#{file} #{status.inspect}"
			end
		end
	end
end

#onlyObject



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

def only
	if @packages.any?
		Set.new(@packages)
	end
end