Sha256: d5a89c4869bfb71007d0bda0a289ee82adb0d5dd4213c81d36c7b2a90e63a8da

Contents?: true

Size: 1.8 KB

Versions: 42

Compression:

Stored size: 1.8 KB

Contents

require "middleman-core/templates"

# CLI Module
module Middleman::Cli

  # A thor task for creating new projects
  class Init < Thor
    check_unknown_options!

    namespace :init

    desc "init NAME [options]", "Create new project NAME"
    available_templates = ::Middleman::Templates.registered.keys.join(", ")
    method_option "template",
      :aliases => "-T",
      :default => "default",
      :desc    => "Use a project template: #{available_templates}"
    method_option "css_dir",
      # :default => "stylesheets",
      :desc    => 'The path to the css files'
    method_option "js_dir",
      # :default => "javascripts",
      :desc    => 'The path to the javascript files'
    method_option "images_dir",
      # :default => "images",
      :desc    => 'The path to the image files'
    method_option "rack",
      :type    => :boolean,
      :default => false,
      :desc    => 'Include a config.ru file'
    method_option "skip-gemfile",
      :type    => :boolean,
      :default => false,
      :desc    => "Don't create a Gemfile"
    method_option "skip-bundle",
      :type    => :boolean,
      :default => false,
      :desc    => "Don't run bundle install"
    method_option "skip-git",
      :type    => :boolean,
      :default => false,
      :desc    => 'Skip Git ignores and keeps'
    # The init task
    # @param [String] name
    def init(name)
      key = options[:template].to_sym
      unless ::Middleman::Templates.registered.has_key?(key)
        raise Thor::Error.new "Unknown project template '#{key}'"
      end

      thor_group = ::Middleman::Templates.registered[key]
      thor_group.new([name], options).invoke_all
    end
  end

  def self.exit_on_failure?
    true
  end

  # Map "i", "new" and "n" to "init"
  Base.map({
    "i"   => "init",
    "new" => "init",
    "n"   => "init"
  })
end

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
middleman-core-3.2.0 lib/middleman-core/cli/init.rb
middleman-core-3.1.6 lib/middleman-core/cli/init.rb
middleman-core-3.1.5 lib/middleman-core/cli/init.rb
middleman-core-3.1.4 lib/middleman-core/cli/init.rb
middleman-core-3.1.3 lib/middleman-core/cli/init.rb
middleman-core-3.1.2 lib/middleman-core/cli/init.rb
middleman-core-3.1.1 lib/middleman-core/cli/init.rb
middleman-core-3.1.0 lib/middleman-core/cli/init.rb
middleman-core-3.1.0.rc.4 lib/middleman-core/cli/init.rb
middleman-core-3.1.0.rc.3 lib/middleman-core/cli/init.rb
middleman-core-3.1.0.rc.2 lib/middleman-core/cli/init.rb
middleman-core-3.1.0.rc.1 lib/middleman-core/cli/init.rb
middleman-core-x86-mingw32-3.0.14 lib/middleman-core/cli/init.rb
middleman-core-3.0.14 lib/middleman-core/cli/init.rb
middleman-core-3.1.0.beta.3 lib/middleman-core/cli/init.rb
middleman-core-3.1.0.beta.2 lib/middleman-core/cli/init.rb
middleman-core-3.1.0.beta.1 lib/middleman-core/cli/init.rb
middleman-core-x86-mingw32-3.0.13 lib/middleman-core/cli/init.rb
middleman-core-3.0.13 lib/middleman-core/cli/init.rb
middleman-core-x86-mingw32-3.0.12 lib/middleman-core/cli/init.rb