sprockets-assistant/lib/sprockets/assistant/cli.rb

41 lines
901 B
Ruby
Raw Permalink Normal View History

require 'rack'
require 'thor'
2012-10-04 20:50:30 +00:00
require 'bundler'
module Sprockets
module Assistant
class CLI < Thor
include Thor::Actions
source_root File.expand_path('../../../..', __FILE__)
desc "server", "server"
method_options %w{port -p} => 8080
def server
2012-08-10 20:09:51 +00:00
require 'sprockets/assistant/server'
$stdout.sync = true
Rack::Handler.default.run(Sprockets::Assistant::Server.app, :Port => options[:port])
end
desc "compile", "compile things"
def compile
2012-08-10 20:09:51 +00:00
require 'sprockets/assistant/app_builder'
Sprockets::Assistant::AppBuilder.new.compile
end
desc "create NAME", "initialize a new assistant project"
def create(name)
directory 'skel', name
2012-08-10 20:09:51 +00:00
Dir.chdir(name) do
Bundler.with_clean_env { system %{bundle} }
end
end
2012-08-10 20:09:51 +00:00
default_task :server
end
end
end