Class: Geb::CLI::Commands::Init

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

Overview

define init command

Instance Method Summary collapse

Instance Method Details

#call(site_path:, **options) ⇒ Object

call method for the init command



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/geb/commands/init.rb', line 37

def call(site_path:, **options)

  # initialize a new site object, this does all sorts of validations and checks, raises errors if something is wrong
  new_site = Geb::Site.new

  # validate the site
  new_site.validate(site_path, options[:template], options[:skip_template], options[:force])

  # validate proposed git repository in the site path if we are not skipping git, will raise error if git situation is unacceptable
  Geb.log "Skipping git repository validation as told." if options[:skip_git]
  Geb::Git.validate_git_repo(site_path) unless options[:skip_git]

  # create the site folder and populate it with the template if we are not skipping the whole process
  new_site.create

  # create the git repository if we are not skipping git
  Geb.log "Skipping git repository creation as told." if options[:skip_git]
  Geb::Git.create_git_repo(site_path) unless options[:skip_git]

rescue Geb::Error => e

  # print error message
  puts
  warn e.message

end