Class: Roda::Project::CLI

Inherits:
Object
  • Object
show all
Includes:
Helpers::Ids, Helpers::Input, Helpers::Template
Defined in:
lib/roda/project/cli.rb

Instance Method Summary collapse

Methods included from Helpers::Ids

#api_id, #fullstack_id, #minitest_id, #mysql_id, #postgresql_id, #rspec_id, #sqlite_id

Methods included from Helpers::Input

#read_line, #reader

Methods included from Helpers::Template

#cp, #cp_r, #tty_cp, #tty_cp_r

Constructor Details

#initialize(context: Context.new, pastel: Pastel.new, dir: nil) ⇒ CLI

Returns a new instance of CLI.



10
11
12
13
14
# File 'lib/roda/project/cli.rb', line 10

def initialize(context: Context.new, pastel: Pastel.new, dir: nil)
  @context = context
  @pastel = pastel
  @dir = dir
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/roda/project/cli.rb', line 16

def call
  puts @pastel.bright_black("[roda-project v#{Roda::Project::VERSION}]\n")
  puts @pastel.italic("#{Roda::Project.messages.sample.first}\n")

  get_user_context

  puts @pastel.bright_black("\n[project: #{@context.project_name}]\n")

  create_base_project
  add_front_end
  add_database
  add_test_files

  puts "\ninstall dependences:\n\n"
  puts "$ cd #{@context.project_name} && bundle"
  if @context.database?
    unless @context.sqlite?
      puts "\n* create your database\n"
      puts "\n* put your dev database credentials in app/config/config.rb\n"
    end
    puts "\nmigrate the database (use RACK_ENV to migrate 'test' or 'production' environments):\n\n"
    puts "$ rake db:migrate"
  end
  puts "\nrun and watch the project in dev mode:\n"
  puts "\n$ rake dev:watch"
  if @context.fullstack?
    puts "\ncompile and watch assets:\n"
    puts "\n$ rake assets:watch"
  end
  puts "\nrun 'rake' inside #{@context.project_name} to see all available tasks\n\n"
rescue TTY::Reader::InputInterrupt
  puts "\n\nGoodbye"
end