Class: GPTerm
- Inherits:
-
Object
- Object
- GPTerm
- Defined in:
- lib/gpterm.rb
Overview
The colours work like this:
-
Output from STDOUT or STDERR is default
-
For the final command, if STDERR is there and the exit code is non-zero, it’s red
-
Statements from this app are magenta
-
Questions from this app are yellow
-
Messages from the OpenAI API are blue
Instance Method Summary collapse
-
#initialize ⇒ GPTerm
constructor
A new instance of GPTerm.
- #run ⇒ Object
Constructor Details
#initialize ⇒ GPTerm
18 19 20 21 22 23 |
# File 'lib/gpterm.rb', line 18 def initialize @config = AppConfig.load @options = ParseOptions.call(@config) @openai_client = OpenAI::Client.new(access_token: @config["openapi_key"]) @command_generator = CommandGenerator.new(@config, @openai_client) end |
Instance Method Details
#run ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gpterm.rb', line 25 def run if @options[:preset_prompt] name = @options[:preset_prompt][0] prompt = @options[:preset_prompt][1] AppConfig.add_preset(@config, name, prompt) ("Preset prompt '#{name}' saved with prompt '#{prompt}'", :green) elsif @options[:prompt] start_conversation(@options[:prompt]) end end |