2011-12-21 21:13:28 +01:00
|
|
|
module Middleman::Cli
|
|
|
|
class Server < Thor
|
2011-12-21 20:03:45 +01:00
|
|
|
check_unknown_options!
|
2011-12-21 21:13:28 +01:00
|
|
|
|
|
|
|
namespace :server
|
|
|
|
|
|
|
|
desc "server [options]", "Start the preview server"
|
|
|
|
method_option "environment",
|
2011-12-21 20:03:45 +01:00
|
|
|
:aliases => "-e",
|
|
|
|
:default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development',
|
|
|
|
:desc => "The environment Middleman will run under"
|
2011-12-21 21:13:28 +01:00
|
|
|
method_option :host,
|
2011-12-21 20:03:45 +01:00
|
|
|
:type => :string,
|
|
|
|
:aliases => "-h",
|
|
|
|
# :required => true,
|
|
|
|
:default => "0.0.0.0",
|
|
|
|
:desc => "Bind to HOST address"
|
2011-12-21 21:13:28 +01:00
|
|
|
method_option "port",
|
2011-12-21 20:03:45 +01:00
|
|
|
:aliases => "-p",
|
|
|
|
:default => "4567",
|
|
|
|
:desc => "The port Middleman will listen on"
|
2011-12-21 21:13:28 +01:00
|
|
|
method_option "debug",
|
2011-12-21 20:03:45 +01:00
|
|
|
:type => :boolean,
|
|
|
|
:default => false,
|
|
|
|
:desc => 'Print debug messages'
|
|
|
|
def server
|
|
|
|
params = {
|
|
|
|
:port => options["port"],
|
|
|
|
:host => options["host"],
|
|
|
|
:environment => options["environment"],
|
|
|
|
:debug => options["debug"]
|
|
|
|
}
|
|
|
|
|
|
|
|
puts "== The Middleman is loading"
|
|
|
|
Middleman::Guard.start(params)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Base.map({ "s" => "server" })
|
|
|
|
end
|