Sha256: a9716541038738b8ec6f2c1e2f78c630cf86e373b8726f0cc71433fff4bd9fbe

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

module Middleman::Cli
  class Init < Thor
    check_unknown_options!
    
    namespace :init
    
    desc "init NAME [options]", "Create new project NAME"
    available_templates = ::Middleman::Templates.registered.keys.join(", ")
    # argument :name
    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 "bundler", 
      :type    => :boolean, 
      :default => false, 
      :desc    => 'Create a Gemfile and use Bundler to manage gems'
    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
  
  Base.map({
    "i"   => "init",
    "new" => "init",
    "n"   => "init"
  })
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
middleman-3.0.0.alpha.6 lib/middleman/cli/init.rb
middleman-3.0.0.alpha.5 lib/middleman/cli/init.rb