Class: SchwarmCli::Commands::SkillsCmd
- Inherits:
-
Base
- Object
- Thor
- Base
- SchwarmCli::Commands::SkillsCmd
show all
- Defined in:
- lib/schwarm_cli/commands/skills.rb
Constant Summary
Constants inherited
from Base
Base::DEFAULT_LIST_LIMIT, Base::INHERITED_OPTIONS
Instance Method Summary
collapse
Methods inherited from Base
exit_on_failure?, pagination_options
Instance Method Details
#create ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/schwarm_cli/commands/skills.rb', line 36
def create
handle_errors do
attrs = {
name: options[:name], description: options[:description],
instructions: read_instructions, global: options[:global]
}
data = client.skills.create(**attrs)
output_record(data, fields: { "ID" => "id", "Name" => "name", "Global" => "global" })
end
end
|
#delete(id) ⇒ Object
62
63
64
65
66
67
|
# File 'lib/schwarm_cli/commands/skills.rb', line 62
def delete(id)
handle_errors do
client.skills.destroy(id)
puts "Skill #{id} deleted."
end
end
|
#list ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/schwarm_cli/commands/skills.rb', line 9
def list
handle_errors do
data = fetch_paged do |page_params|
client.skills.list(query: options[:query], **page_params)
end
output_list(data, columns: [%w[ID id], %w[NAME name], %w[GLOBAL global]])
end
end
|
#show(id) ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/schwarm_cli/commands/skills.rb', line 19
def show(id)
handle_errors do
data = client.skills.find(id)
output_record(data, fields: {
"ID" => "id", "Name" => "name", "Description" => "description",
"Instructions" => "instructions", "Global" => "global",
"Created" => "created_at"
})
end
end
|
#update(id) ⇒ Object
54
55
56
57
58
59
|
# File 'lib/schwarm_cli/commands/skills.rb', line 54
def update(id)
handle_errors do
data = client.skills.update(id, **update_attrs)
output_record(data, fields: { "ID" => "id", "Name" => "name", "Global" => "global" })
end
end
|