Class: Agentd::TaskCommands
- Inherits:
-
Thor
- Object
- Thor
- Agentd::TaskCommands
show all
- Includes:
- CLIHelpers
- Defined in:
- lib/agentd/cli.rb
Overview
Instance Method Summary
collapse
Methods included from CLIHelpers
#build_agent, #build_client, #format_json, #status_color
Instance Method Details
#claim(task_id) ⇒ Object
132
133
134
135
|
# File 'lib/agentd/cli.rb', line 132
def claim(task_id)
r = build_agent(options).claim_task(task_id.to_i)
say "Task ##{r["id"]} claimed", :green
end
|
#complete(task_id) ⇒ Object
139
140
141
142
|
# File 'lib/agentd/cli.rb', line 139
def complete(task_id)
r = build_agent(options).complete_task(task_id.to_i, result: JSON.parse(options[:result]))
say "Task ##{r["id"]} completed.", :green
end
|
#delegate(handle) ⇒ Object
114
115
116
117
118
119
120
121
122
|
# File 'lib/agentd/cli.rb', line 114
def delegate(handle)
result = build_agent(options).delegate_task(
to: handle,
title: options[:title],
instructions: options[:instructions],
payload: options[:payload] || {}
)
say "Task ##{result["id"]} delegated to #{handle}", :green
end
|
#fail(task_id) ⇒ Object
146
147
148
149
|
# File 'lib/agentd/cli.rb', line 146
def fail(task_id)
build_agent(options).fail_task(task_id.to_i, reason: options[:reason])
say "Task ##{task_id} marked failed.", :yellow
end
|
#inbox ⇒ Object
105
106
107
108
|
# File 'lib/agentd/cli.rb', line 105
def inbox
tasks = build_agent(options).inbox(limit: options[:limit])
tasks.empty? ? say("Inbox empty.", :green) : tasks.each { |t| print_task(t) }
end
|
#result(task_id) ⇒ Object
125
126
127
128
129
|
# File 'lib/agentd/cli.rb', line 125
def result(task_id)
r = build_agent(options).task_result(task_id.to_i)
say "Status: #{r["remote_status"]}", status_color(r["remote_status"])
puts format_json(r["remote_result"]) if r["remote_result"]
end
|