7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/clag/commands/generate.rb', line 7
def call(args, _name)
input = args.join(" ")
if ENV['OPENAI_API_KEY'].nil?
puts CLI::UI.fmt("{{red:OPENAI_API_KEY is not set. Please set it before continuing.}}")
return
end
if input.nil?
puts "Please provide input to generate options."
return
end
results = Sublayer::Agents::GenerateCommandLineCommandAgent.new(description: input).execute
if results == 'unknown'
puts CLI::UI.fmt("{{yellow:Unable to generate command. Please try again or provide more information.}}")
return
end
Clipboard.copy(results)
puts "\e[1;32m#{results}\e[0m\nCopied to clipboard."
end
|