Class: SchwarmCli::Commands::SkillFilesCmd

Inherits:
Base
  • Object
show all
Defined in:
lib/schwarm_cli/commands/skill_files.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

#createObject



32
33
34
35
36
37
38
39
40
# File 'lib/schwarm_cli/commands/skill_files.rb', line 32

def create
  handle_errors do
    data = client.skill_files.create(
      skill_id: options[:skill], path: options[:path],
      content: read_content(required: true)
    )
    output_record(data, fields: skill_file_fields)
  end
end

#delete(id) ⇒ Object



59
60
61
62
63
64
# File 'lib/schwarm_cli/commands/skill_files.rb', line 59

def delete(id)
  handle_errors do
    client.skill_files.destroy(skill_id: options[:skill], id:)
    puts "Skill file #{id} deleted."
  end
end

#listObject



9
10
11
12
13
14
15
16
# File 'lib/schwarm_cli/commands/skill_files.rb', line 9

def list
  handle_errors do
    data = fetch_paged do |page_params|
      client.skill_files.list(skill_id: options[:skill], **page_params)
    end
    output_list(data, columns: [%w[ID id], %w[PATH path], %w[CREATED created_at]])
  end
end

#show(id) ⇒ Object



20
21
22
23
24
25
# File 'lib/schwarm_cli/commands/skill_files.rb', line 20

def show(id)
  handle_errors do
    data = client.skill_files.find(skill_id: options[:skill], id:)
    output_record(data, fields: skill_file_fields)
  end
end

#update(id) ⇒ Object



47
48
49
50
51
52
53
54
55
# File 'lib/schwarm_cli/commands/skill_files.rb', line 47

def update(id)
  handle_errors do
    data = client.skill_files.update(
      skill_id: options[:skill], id:,
      path: options[:path], content: read_content(required: false)
    )
    output_record(data, fields: skill_file_fields)
  end
end