Class: Ocak::Commands::Init

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/ocak/commands/init.rb

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ocak/commands/init.rb', line 21

def call(**options)
  project_dir = Dir.pwd

  if File.exist?(File.join(project_dir, 'ocak.yml')) && !options[:force]
    puts 'ocak.yml already exists. Use --force to overwrite.'
    return
  end

  puts 'Detecting project stack...'
  stack = StackDetector.new(project_dir).detect
  print_stack(stack)

  generator = AgentGenerator.new(
    stack: stack, project_dir: project_dir, use_ai: !options[:no_ai], logger: init_logger
  )

  generate_files(generator, project_dir, options)
  update_settings(project_dir, stack)
  update_gitignore(project_dir)
  create_labels(project_dir)

  puts ''
  print_summary(project_dir, stack, options)
end