Class: SchwarmCli::Commands::SkillsCmd
- Defined in:
- lib/schwarm_cli/commands/skills.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/schwarm_cli/commands/skills.rb', line 30 def create handle_errors do attrs = { name: [:name], global: [:global] } attrs[:description] = [:description] if [:description] data = client.skills.create(**attrs) output_record(data, fields: { "ID" => "id", "Name" => "name", "Global" => "global" }) end end |
#delete(id) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/schwarm_cli/commands/skills.rb', line 52 def delete(id) handle_errors do client.skills.destroy(id) puts "Skill #{id} deleted." end end |
#list ⇒ Object
8 9 10 11 12 13 |
# File 'lib/schwarm_cli/commands/skills.rb', line 8 def list handle_errors do data = client.skills.list(query: [:query]) output_list(data, columns: [%w[ID id], %w[NAME name], %w[GLOBAL global]]) end end |
#show(id) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/schwarm_cli/commands/skills.rb', line 16 def show(id) handle_errors do data = client.skills.find(id) output_record(data, fields: { "ID" => "id", "Name" => "name", "Description" => "description", "Global" => "global", "Created" => "created_at" }) end end |
#update(id) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/schwarm_cli/commands/skills.rb', line 44 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 |