Sha256: 0d64da6e23b5ee41fe28a4c5ab52844223b4b709b425481a84f79b80b224a2f1

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require 'specimen/generator'

module Specimen
  module Command
    class InitCommand < BaseGroup
      class RequiredOptionError < StandardError
        def initialize
          @msg = "Please provide required option '--name'!"
          super(@msg)
        end
      end

      class ProjectNameError < StandardError
        def initialize
          @msg = "Option '--name' can not be empty or equal 'name'!"
          super(@msg)
        end
      end

      def self.source_root
        File.dirname(__FILE__)
      end

      namespace :init

      class_option :name, aliases: %w[-n], type: :string
      class_option :skip_ui, type: :boolean, default: false
      class_option :ui_driver, type: :string, default: ''
      class_option :skip_cucumber, type: :boolean, default: false
      class_option :skip_rspec, type: :boolean, default: false

      no_commands do
        def perform
          run_options_checks!

          Generator::SpecimenProjectGenerator.new(args, options).perform
        end

        def run_options_checks!
          raise RequiredOptionError if options[:name].nil?
          raise RequiredOptionError if options[:name].empty?
          raise ProjectNameError if options[:name] == 'name'
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
specimen-0.0.4.alpha lib/specimen/commands/init/init_command.rb
specimen-0.0.3.alpha lib/specimen/commands/init/init_command.rb
specimen-0.0.2.alpha lib/specimen/commands/init/init_command.rb