Class: LazyRails::Commands::New

Inherits:
Thor
  • Object
show all
Includes:
NewCommand::Options
Defined in:
lib/lazy_rails/commands/new.rb

Constant Summary collapse

RAILS_NEW_COMMAND =
["rails new"]

Instance Method Summary collapse

Instance Method Details

#newObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/lazy_rails/commands/new.rb', line 12

def new
  puts "Welcome to the Rails Project Setup Wizard!"

  app_name = PromptGenerators::AppName.new(prompt).call
  selected_db = PromptGenerators.new(prompt).call
  selected_app_type = PromptGenerators::SelectAppType.new(prompt).call

  if selected_app_type == "web"
    selected_js = PromptGenerators::SelectJs.new(prompt).call
    selected_css = PromptGenerators::SelectCss.new(prompt).call
  end

  selected_tools = PromptGenerators::SelectTools.new(prompt).call

  rails_new_command = RAILS_NEW_COMMAND.compact.join(" ")

  # Display the final command
  puts "\nYour Rails project will be created with the following command:"
  puts rails_new_command

  # Ask for confirmation
  if prompt.yes?("Do you want to run this command now?")
    system(rails_new_command)
    puts "Rails project '#{project_name}' has been created!"
  else
    puts "Command not executed. You can run it manually when you're ready."
  end
end