Class: Makit::Cli::InitProjectCommand

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/makit/cli/project_commands.rb

Overview

Initialize existing directory as project

Instance Method Summary collapse

Instance Method Details

#executeObject



560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
# File 'lib/makit/cli/project_commands.rb', line 560

def execute
  init_path = File.expand_path(path)

  unless Dir.exist?(init_path)
    puts "Error: Directory does not exist: #{init_path}"
    exit 1
  end

  detected_type = detect_project_type(init_path)
  actual_type = type == "auto" ? detected_type : type

  if actual_type == "unknown"
    puts "Error: Could not detect project type. Please specify --type explicitly."
    exit 1
  end

  puts "Initializing #{actual_type} project in: #{init_path}"

  if has_project_files?(init_path, actual_type) && !force?
    puts "Error: Project files already exist. Use --force to overwrite."
    exit 1
  end

  initialize_project(init_path, actual_type)
  puts "✅ Successfully initialized #{actual_type} project"
end