Sha256: 9f0e057d51a69fe7bca568278f9aa6c6384dcc32200b139f8721e8ad4cdaf08f

Contents?: true

Size: 1.58 KB

Versions: 38

Compression:

Stored size: 1.58 KB

Contents

require 'optparse'
require 'fileutils'


module Remi
  module Cli
    extend self

    def execute
      parse
      initialize_project if @options[:init] == true
    end

    def parse(args = ARGV)
      options = {}

      opt_parser = OptionParser.new do |opts|
        opts.banner = <<-EOT.strip_heredoc
          Usage: Command line helpers for Remi.
        EOT

        opts.on('-h', '--help', 'Show this message') do
          puts opts
          exit
        end

        options[:init] = false
        opts.on('-i', '--init', 'Initialze a new Remi project') do
          options[:init] = true
        end
      end
      opt_parser.parse!(args)

      @options = options
    end

    def initialize_project
      template_dir = File.expand_path(File.join(File.dirname(__FILE__),'../../'))

      FileUtils.mkdir_p "features"
      FileUtils.cp(File.join(template_dir, 'features/sample_job.feature'), 'features')

      FileUtils.mkdir_p "features/support"
      FileUtils.cp(File.join(template_dir, 'features/support/env.rb'), 'features/support')
      FileUtils.cp(File.join(template_dir, 'features/support/env_app.rb'), 'features/support') unless File.exist?('features/support/env_app.rb')

      FileUtils.mkdir_p "features/step_definitions"
      FileUtils.cp(File.join(template_dir, 'features/step_definitions/remi_step.rb'), 'features/step_definitions')

      FileUtils.mkdir_p "jobs"
      FileUtils.cp(File.join(template_dir, 'jobs/all_jobs_shared.rb'), 'jobs') unless File.exist?('jobs/all_jobs_shared.rb')
      FileUtils.cp(File.join(template_dir, 'jobs/sample_job.rb'), 'jobs')
    end

  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
remi-0.2.26 lib/remi/cli.rb
remi-0.2.25 lib/remi/cli.rb
remi-0.2.24 lib/remi/cli.rb
remi-0.2.23 lib/remi/cli.rb
remi-0.2.22 lib/remi/cli.rb
remi-0.2.21 lib/remi/cli.rb
remi-0.2.20 lib/remi/cli.rb
remi-0.2.19 lib/remi/cli.rb
remi-0.2.18 lib/remi/cli.rb
remi-0.2.17 lib/remi/cli.rb
remi-0.2.16 lib/remi/cli.rb
remi-0.2.15 lib/remi/cli.rb
remi-0.2.14 lib/remi/cli.rb
remi-0.2.13 lib/remi/cli.rb
remi-0.2.12 lib/remi/cli.rb
remi-0.2.11 lib/remi/cli.rb
remi-0.2.10 lib/remi/cli.rb
remi-0.2.9 lib/remi/cli.rb