Class: Yadecli::Command::Project::ProjectListCommand

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

Instance Method Summary collapse

Instance Method Details

#executeObject



11
12
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
38
39
40
41
42
43
44
45
46
# File 'lib/yadecli/command/project/project_list_command.rb', line 11

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

  projects = project_client.list

  projects.each do |p|
    puts "Project: #{p.name}".colorize(mode: :bold)

    project_modules = project_module_client.modules_for_project(p.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

      if is_installed
        current_branch = FileUtil.git_current_branch(p.home)
      else
        current_branch = '-'
      end

      rows << [module_name, is_installed, git_status, current_branch]
    end
    table = TTY::Table.new header: ['Module name', 'Installed', 'Git Status', 'Branch'], rows: rows
    puts table.render(:ascii, padding: [0, 1])
  end

  """
You can run 'yadecli project install <project_name>' to install a project

You can run 'yadecli module install <project_name> <module_name>' to install a module to a project
  """
end