Sha256: 98e7f617216aeb5f71c62c500b82bd5347cd745bfa982baf0b7856da5b61bdde

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

#!/usr/bin/env ruby
require 'gli'
require_relative '../lib/howitzer/version'

module HowitzerCli

  extend GLI::App
  synopsis_format :compact
  program_desc 'Ruby based framework for acceptance testing'
  version Howitzer::VERSION

  desc 'Generate new project'
  arg_name '<PROJECT NAME>'
  command :new do |c|
    c.desc 'Integrate Cucumber'
    c.switch [:c, :cucumber] , negatable: false

    c.desc 'Integrate Rspec'
    c.switch [:r, :rspec], negatable: false

    c.action do |global_options, options, args|
      if args.size > 0
        validate_options(options)
        Dir[File.join(File.dirname(__FILE__), '..', 'generators', '**', '*_generator.rb')].each{ |f| require File.expand_path(f) }
        path_to_dir = File.join(Dir.pwd, args.first)
        puts "  * New project directory creation ..."
        Dir.mkdir(path_to_dir)
        puts "      Created new './#{args.first}' folder"
        Dir.chdir(path_to_dir)
        Howitzer::ConfigGenerator.new
        Howitzer::PagesGenerator.new
        Howitzer::TasksGenerator.new
        Howitzer::EmailsGenerator.new
        Howitzer::RootGenerator.new
        Howitzer::CucumberGenerator.new if options['cucumber']
        Howitzer::RspecGenerator.new if options['rspec']
        puts "[WARN] Extra parameters were skipped" if args.size > 1
      elsif args.size.zero?
        exit_now!("Please specify <PROJECT NAME>", 64)
      end
    end
  end

  def self.call
    exit run(ARGV)
  end

  class << self
    private
    def validate_options(options)
      if !options['cucumber'] && !options['rspec']
        exit_now!("Provide --cucumber and/or --rspec option", 64)
      end
    end
  end
end

unless ENV['TEST_MODE']
  HowitzerCli.call
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
howitzer-1.0.2 bin/howitzer