Class: Yadecli::Command::Module::ModuleListCommand

Inherits:
Mutations::Command
  • Object
show all
Defined in:
lib/yadecli/command/module/module_list_command.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/yadecli/command/module/module_list_command.rb', line 22

def execute
  project_client = Yade::Project::Rest::Client::ProjectClient.new
  project_module_client = Yade::Project::Rest::Client::ProjectModuleClient.new

  project = project_client.project_by_name(self.project_name)

  puts "Project: #{project.name}".colorize(:mode => :bold)

  project_modules = project_module_client.modules_for_project(project.id)

  rows = []
  project_modules.each do |m|
    module_name = m.name
    is_installed = m.installed?
    git_status = '-'
    git_status = FileUtil.git_status(m.home) if is_installed
    rows << [module_name, is_installed, git_status]
  end
  table = TTY::Table.new header: ['Module name', 'Installed', 'Git Status'], rows: rows

  table.render(:ascii, padding: [0, 1])
end