Class: Yadecli::Command::Task::TaskListCommand

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

Instance Method Summary collapse

Instance Method Details

#executeObject



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
47
48
49
50
51
52
# File 'lib/yadecli/command/task/task_list_command.rb', line 20

def execute
  #puts "Task project_name: #{project_name} module_name: #{module_name}"

  project_client = Yade::Project::Rest::Client::ProjectClient.new
  project_task_client = Yade::Project::Rest::Client::ProjectTaskClient.new

  project = project_client.project_by_name(project_name)

  git_add_all_step = Yade::Project::Rest::Model::ProjectTaskStep.new({id: 1, name: 'git-add-all', command: 'git add .'})
  git_commit_step = Yade::Project::Rest::Model::ProjectTaskStep.new({id: 2, name: 'git-commit', command: 'git commit -m "ncm"'})
  git_push_step = Yade::Project::Rest::Model::ProjectTaskStep.new({id: 3, name: 'git-push', command: 'git push origin develop'})
  git_pull_step = Yade::Project::Rest::Model::ProjectTaskStep.new({id: 4, name: 'git-pull', command: 'git pull origin develop'})

  project_tasks = [
      Yade::Project::Rest::Model::ProjectTask.new({id: 1,
                                                   name: 'commit-and-push',
                                                   desc: 'commit and push all changes for all project modules',
                                                   steps: [git_add_all_step, git_commit_step, git_push_step]}),
      Yade::Project::Rest::Model::ProjectTask.new({id: 2,
                                                   name: 'pull',
                                                   desc: 'pull all changes for all project modules',
                                                   steps: [git_pull_step]})
  ]

  table = TTY::Table.new header: ['Name', 'Description', 'Steps']

  project_tasks.each do |pt|
    table << [pt.name, pt.desc, pt.steps.map { |s| s.name }.join(", ")]
  end

  puts "Project #{project.name}"
  puts table.render(:ascii, width: 120, resize: true, padding: [0, 1])
end