require'thor'moduleMiddlemanclassCLI<ThorincludeThor::Actionscheck_unknown_options!default_task:serverclass_option"help",:type=>:boolean,:default=>false,:aliases=>"-h"definitialize(*)superhelp_checkifoptions[:help]enddesc"init NAME","Create new Middleman project directory NAME"available_templates=Middleman::Templates.registered_names.join(", ")method_option"template",:aliases=>"-T",:default=>"default",:desc=>"Optionally use a pre-defined 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'definit(name)key=options[:template].to_symunlessMiddleman::Templates.registered_templates.has_key?(key)key=:defaultendthor_group=Middleman::Templates.registered_templates[key]thor_group.new([name],options).invoke_allenddesc"server [-p 4567] [-e development]","Starts the Middleman preview server"method_option"environment",:aliases=>"-e",:default=>ENV['MM_ENV']||ENV['RACK_ENV']||'development',:desc=>"The environment Middleman will run under"method_option"port",:aliases=>"-p",:default=>"4567",:desc=>"The port Middleman will listen on"method_option"livereload",:default=>false,:type=>:boolean,:desc=>"Whether to enable Livereload or not"method_option"livereload-port",:default=>"35729",:desc=>"The port Livereload will listen on"defserverv1_checkifoptions["livereload"]livereload_options={:port=>options["livereload-port"]}endMiddleman::Guard.start({:port=>options[:port],:environment=>options[:environment]},livereload_options)enddesc"build","Builds the static site for deployment"method_option"relative",:type=>:boolean,:aliases=>"-r",:default=>false,:desc=>'Override the config.rb file and force relative urls'defbuildv1_checkthor_group=Middleman::Builder.new([],options).invoke_allenddesc"migrate","Migrates an older Middleman project to the 2.0 structure"defmigratereturnifFile.exists?("source")`mv public source``cp -R views/* source/``rm -rf views`enddesc"version","Show Middleman version"defversionrequire'middleman/version'say"Middleman #{Middleman::VERSION}"endprivatedefv1_checkifFile.exists?("views")||File.exists?("public")$stderr.puts"== Error: The views and public folders are have been combined. Use the 'middleman migrate' command to merge your folders automatically."exit1endenddefhelp_checkhelpself.class.send(:retrieve_task_name,ARGV.dup)exit0endendend