Sha256: e0ffcac1a0a2c978cbc855cc1e24701a3178041770c4abe056e309dee0b9a74f
Contents?: true
Size: 1005 Bytes
Versions: 2
Compression:
Stored size: 1005 Bytes
Contents
require 'clag' require "clipboard" module Clag module Commands class Generate < Clag::Command 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 = Clag::CommandLineCommandGenerator.new(description: input).generate 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 def self.help "Generate a command-line command and store it in the clipboard. \nUsage: {{command:#{Clag::TOOL_NAME} g \"the command you want to generate\"}}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
clag-0.0.7 | lib/clag/commands/generate.rb |
clag-0.0.6 | lib/clag/commands/generate.rb |