#!/usr/bin/env ruby require 'optparse' # Require Middleman require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman') env = ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development' options = {} livereload_options = {} # TODO: Switch to Thor OptionParser.new { |opts| opts.banner = "Usage: mm-server [rack options]" opts.separator "" opts.separator "Rack options:" opts.on("-p", "--port PORT", "use PORT (default: 4567)") { |port| options[:port] = port } opts.on("-E", "--env ENVIRONMENT", "use ENVIRONMENT for defaults (default: development)") { |e| env = e } opts.on("--livereload_port PORT", "use PORT (default: 35729)") { |port| livereload_options[:port] = port } opts.parse! ARGV } ENV['RACK_ENV'] = env if !File.exists?("config.rb") $stderr.puts "== Error: Could not find a Middleman project config, perhaps you are in the wrong folder?" exit end # If the old directories exists, use it, but issue warning if File.exists?("views") || File.exists?("public") $stderr.puts "== Error: The views and public folders are have been combined. Create a new 'source' folder, add the contents of views and public to it and then remove the empty views and public folders." exit end Middleman::Guard.start(options, livereload_options)