Class: SchwarmCli::Commands::Tasks
- Defined in:
- lib/schwarm_cli/commands/tasks.rb
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
- #archive(id) ⇒ Object
- #create ⇒ Object
- #delete(id) ⇒ Object
- #handoff ⇒ Object
- #list ⇒ Object
- #message(id) ⇒ Object
- #pause(id) ⇒ Object
- #reset(id) ⇒ Object
- #retry(id) ⇒ Object
- #show(id) ⇒ Object
- #start(id) ⇒ Object
- #update(id) ⇒ Object
Methods inherited from Base
Instance Method Details
#archive(id) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/schwarm_cli/commands/tasks.rb', line 75 def archive(id) handle_errors do data = client.tasks.archive(id) puts "Task #{id} archived (#{data.dig('data', 'status')})." end end |
#create ⇒ Object
39 40 41 42 43 44 |
# File 'lib/schwarm_cli/commands/tasks.rb', line 39 def create handle_errors do data = client.tasks.create(**create_attrs) output_record(data, fields: { "ID" => "id", "Name" => "name", "Status" => "status" }) end end |
#delete(id) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/schwarm_cli/commands/tasks.rb', line 59 def delete(id) handle_errors do client.tasks.destroy(id) puts "Task #{id} deleted." end end |
#handoff ⇒ Object
120 121 122 123 124 125 126 127 128 |
# File 'lib/schwarm_cli/commands/tasks.rb', line 120 def handoff prompt = [:prompt] abort "Error: --prompt is required." if prompt.nil? || prompt.strip.empty? handle_errors do result = SchwarmCli::HandsOffTask.new(client: client).call(**handoff_attrs(prompt)) print_handoff_result(result) end end |
#list ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/schwarm_cli/commands/tasks.rb', line 11 def list handle_errors do data = fetch_paged { |page_params| client.tasks.list(**list_attrs, **page_params) } output_list(data, columns: [%w[ID id], %w[NAME name], %w[STATUS status], %w[REPO github_repository_name], %w[CREATED created_at]]) end end |
#message(id) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/schwarm_cli/commands/tasks.rb', line 108 def (id) handle_errors do client..create(task_id: id, content: [:content]) puts "Message sent to task #{id}." end end |
#pause(id) ⇒ Object
99 100 101 102 103 104 |
# File 'lib/schwarm_cli/commands/tasks.rb', line 99 def pause(id) handle_errors do data = client.tasks.pause(id) puts "Task #{id} paused (#{data.dig('data', 'status')})." end end |
#reset(id) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/schwarm_cli/commands/tasks.rb', line 91 def reset(id) handle_errors do data = client.tasks.reset(id) puts "Task #{id} reset (#{data.dig('data', 'status')})." end end |
#retry(id) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/schwarm_cli/commands/tasks.rb', line 83 def retry(id) handle_errors do data = client.tasks.retry(id) puts "Task #{id} retried (#{data.dig('data', 'status')})." end end |
#show(id) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/schwarm_cli/commands/tasks.rb', line 20 def show(id) handle_errors do data = client.tasks.find(id) output_record(data, fields: { "ID" => "id", "Name" => "name", "Status" => "status", "Prompt" => "prompt", "Branch" => "branch_name", "Error" => "error_message", "Repository" => "github_repository_id", "Dependencies" => "dependency_ids", "Created" => "created_at", "Updated" => "updated_at" }) end end |
#start(id) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/schwarm_cli/commands/tasks.rb', line 67 def start(id) handle_errors do data = client.tasks.start(id) puts "Task #{id} started (#{data.dig('data', 'status')})." end end |
#update(id) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/schwarm_cli/commands/tasks.rb', line 51 def update(id) handle_errors do data = client.tasks.update(id, **update_attrs) output_record(data, fields: { "ID" => "id", "Name" => "name", "Status" => "status" }) end end |