Sha256: 66df3192bc9b39bca1a223c38556b3679f3ea25c0fb2767704c786b941a7e56e

Contents?: true

Size: 1.44 KB

Versions: 36

Compression:

Stored size: 1.44 KB

Contents

require 'power_stencil/engine/init_engine'

module PowerStencil
  module CommandProcessors

    class Init

      include Climatic::Proxy
      include PowerStencil::CommandProcessors::TraceHelper

      def check_params(params)
        true
      end

      def execute
        setup_project_path
        log_startup_context
        puts_and_logs "Creating new project structure in '#{config[:'project-path']}'"
        PowerStencil::Project::Base.create_project_tree config[:'project-path']
        puts_and_logs 'Done.'
      end

      private

      def setup_project_path
        if config[:'project-path']
          unless  config.command_line_layer.extra_parameters.empty?
            raise PowerStencil::Error, 'You can specify the project path only once !'
          end
        else
          if config.command_line_layer.extra_parameters.size > 1
            raise PowerStencil::Error, 'You can specify the project path only once !'
          end
        end
        config[:'project-path'] = if config[:'project-path']
                                    File.expand_path config[:'project-path']
                                  elsif config.command_line_layer.extra_parameters.size == 1
                                    File.expand_path config.command_line_layer.extra_parameters.first
                                  else
                                    File.expand_path Dir.pwd
                                  end
      end

    end

  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
power_stencil-0.6.0 lib/power_stencil/command_processors/init.rb
power_stencil-0.5.1 lib/power_stencil/command_processors/init.rb
power_stencil-0.5.0 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.22 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.21 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.20 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.19 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.18 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.17 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.16 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.15 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.14 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.13 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.12 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.11 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.10 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.9 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.8 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.7 lib/power_stencil/command_processors/init.rb
power_stencil-0.4.6 lib/power_stencil/command_processors/init.rb