Class: LLMs::CLI::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/llms/cli/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command_name, override_default_options = {}) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
# File 'lib/llms/cli/base.rb', line 8

def initialize(command_name, override_default_options = {})
  @command_name = command_name
  @options = default_options.merge(override_default_options)
  parse_options
end

Instance Attribute Details

#executorObject (readonly)

Returns the value of attribute executor.



6
7
8
# File 'lib/llms/cli/base.rb', line 6

def executor
  @executor
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/llms/cli/base.rb', line 6

def options
  @options
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/llms/cli/base.rb', line 14

def run
  setup
  execute
  cleanup
rescue LLMs::Error => e
  $stderr.puts "Error: #{e.message}"
  exit 1
rescue StandardError => e
  $stderr.puts "Unexpected error: #{e.message}"
  if @options[:debug]
    $stderr.puts e.backtrace
  end
  exit 1
end