Class: Llmemory::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(argv) ⇒ Object



14
15
16
# File 'lib/llmemory/cli.rb', line 14

def self.run(argv)
  new.run(argv)
end

Instance Method Details

#run(argv) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/llmemory/cli.rb', line 18

def run(argv)
  argv = argv.dup
  return print_help if argv.empty?
  first = argv.first
  if first == "--help" || first == "-h"
    print_help
    return
  end
  subcommand = argv.shift
  command_class = find_command(subcommand)
  if command_class
    command_class.new.run(argv)
  else
    $stderr.puts "llmemory: unknown command '#{subcommand}'"
    $stderr.puts "Run 'llmemory --help' for usage."
    exit 1
  end
end