class Stylish::Server def self.start(options={}) require 'rack' require 'rack/server' require 'pry' Stylish.config.apply(:library_path => Pathname(options.library_path)) config = Stylish.lib_root.join 'stylish', 'api.ru' Rack::Server.start :config => config.to_s, :Port => options.port, :Host => options.host end end command "server" do |c| c.syntax = "stylish server [OPTIONS]" c.description = "start the stylish server" c.option '--port PORT', String, 'Which port to listen on?' c.option '--host HOSTNAME', String, 'Which host to listen on?' c.option '--library-path PATH', nil, 'Which library should we load?' c.action do |args, options| options.default(:port => 8090, :host => "0.0.0.0", :library_path => Dir.pwd) Stylish::Server.start(options) end end