Class: Sublayer::Commands::QuickScriptProject

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/sublayer/cli/commands/quick_script_project.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



11
12
13
# File 'lib/sublayer/cli/commands/quick_script_project.rb', line 11

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#ask_for_project_detailsObject



19
20
21
22
# File 'lib/sublayer/cli/commands/quick_script_project.rb', line 19

def ask_for_project_details
  @ai_provider = options[:provider] || ask("Select an AI provider:", default: "OpenAI", limited_to: %w[OpenAI Claude Gemini])
  @ai_model = options[:model] || select_ai_model
end

#copy_template_filesObject



30
31
32
33
34
# File 'lib/sublayer/cli/commands/quick_script_project.rb', line 30

def copy_template_files
  say "Copying template files", :green

  directory "../templates/quick_script", project_name
end

#create_project_directoryObject



24
25
26
27
28
# File 'lib/sublayer/cli/commands/quick_script_project.rb', line 24

def create_project_directory
  say "Creating project directory", :green

  empty_directory project_name
end

#finalize_projectObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/sublayer/cli/commands/quick_script_project.rb', line 45

def finalize_project
  inside(project_name) do
    append_to_file "#{project_name}.rb" do
      "        puts \"Welcome to your quick Sublayer script!\"\n        puts \"To get started, create some generators, actions, or agents in their respective directories and call them here\"\n        puts \"For more information, visit https://docs.sublayer.com\"\n      INSTRUCTIONS\n    end\n\n    run(\"git init\") if yes?(\"Initialize a git repository?\")\n  end\nend\n"

#generate_configurationObject



36
37
38
39
40
41
42
43
# File 'lib/sublayer/cli/commands/quick_script_project.rb', line 36

def generate_configuration
  append_to_file File.join(project_name, "#{project_name}.rb") do
    "      Sublayer.configuration.ai_provider = Sublayer::Providers::\#{@ai_provider}\n      Sublayer.configuration.ai_model = \"\#{@ai_model}\"\n    CONFIG\n  end\nend\n"


59
60
61
62
63
64
# File 'lib/sublayer/cli/commands/quick_script_project.rb', line 59

def print_next_steps
  say "\nSublayer project '#{project_name}' created successfully!", :green
  say "To get started, run:"
  say "  cd #{project_name}"
  say "  ruby #{project_name}.rb"
end

#sublayer_versionObject



15
16
17
# File 'lib/sublayer/cli/commands/quick_script_project.rb', line 15

def sublayer_version
  Sublayer::VERSION
end