Class: OmniAI::CLI
- Inherits:
-
Object
- Object
- OmniAI::CLI
- Defined in:
- lib/omniai/cli.rb,
lib/omniai/cli/base_handler.rb,
lib/omniai/cli/chat_handler.rb,
lib/omniai/cli/embed_handler.rb
Overview
Defined Under Namespace
Classes: BaseHandler, ChatArgs, ChatHandler, EmbedHandler
Instance Method Summary collapse
-
#initialize(stdin: $stdin, stdout: $stdout, provider: 'openai') ⇒ CLI
constructor
A new instance of CLI.
- #parse(argv = ARGV) ⇒ Object
Constructor Details
#initialize(stdin: $stdin, stdout: $stdout, provider: 'openai') ⇒ CLI
Returns a new instance of CLI.
18 19 20 21 22 23 |
# File 'lib/omniai/cli.rb', line 18 def initialize(stdin: $stdin, stdout: $stdout, provider: 'openai') @stdin = stdin @stdout = stdout @provider = provider @args = {} end |
Instance Method Details
#parse(argv = ARGV) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/omniai/cli.rb', line 26 def parse(argv = ARGV) parser.order!(argv) command = argv.shift return if command.nil? handler = case command when 'chat' then ChatHandler when 'embed' then EmbedHandler else raise Error, "unsupported command=#{command.inspect}" end handler.handle!(stdin: @stdin, stdout: @stdout, provider: @provider, argv:) end |