Sha256: 4dd40bd53a7ca1db06329c3e2b2a59120c9c46403b1c685686be4f279d79e7e6

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require 'fileutils'
require 'colorize'
require 'active_support/core_ext/string'
require 'thor'
require 'bundler'

class CliTemplate::Sequence < Thor::Group
  include Thor::Actions
  include CliTemplate::Helpers

  def self.source_root
    template = ENV['TEMPLATE'] || 'default'
    File.expand_path("../../templates/#{template}", __FILE__)
  end

private
  def clone_project
    unless git_installed?
      abort "Unable to detect git installation on your system.  Git needs to be installed in order to use the --repo option."
    end

    if File.exist?(project_name)
      abort "The folder #{project_name} already exists."
    else
      run "git clone https://github.com/#{options[:repo]} #{project_name}"
    end
    confirm_cli_project
  end

  def confirm_cli_project
    cli_project = File.exist?("#{project_name}/config/application.rb")
    unless cli_project
      puts "It does not look like the repo #{options[:repo]} is a cli project. Maybe double check that it is?  Exited.".colorize(:red)
      exit 1
    end
  end

  def copy_project
    puts "Creating new project called #{project_name}."
    directory ".", project_name
  end

  def git_installed?
    system("type git > /dev/null")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cli-template-3.2.0 lib/cli-template/sequence.rb