2012-08-10 15:35:06 +00:00
|
|
|
require 'rack'
|
|
|
|
require 'thor'
|
2012-10-04 20:50:30 +00:00
|
|
|
require 'bundler'
|
2012-08-10 15:35:06 +00:00
|
|
|
|
|
|
|
module Sprockets
|
|
|
|
module Assistant
|
|
|
|
class CLI < Thor
|
|
|
|
include Thor::Actions
|
|
|
|
source_root File.expand_path('../../../..', __FILE__)
|
|
|
|
|
|
|
|
desc "server", "server"
|
2012-08-13 18:25:18 +00:00
|
|
|
method_options %w{port -p} => 8080
|
2012-08-10 15:35:06 +00:00
|
|
|
def server
|
2012-08-10 20:09:51 +00:00
|
|
|
require 'sprockets/assistant/server'
|
|
|
|
|
2012-08-13 18:25:18 +00:00
|
|
|
$stdout.sync = true
|
|
|
|
|
|
|
|
Rack::Handler.default.run(Sprockets::Assistant::Server.app, :Port => options[:port])
|
2012-08-10 15:35:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "compile", "compile things"
|
|
|
|
def compile
|
2012-08-10 20:09:51 +00:00
|
|
|
require 'sprockets/assistant/app_builder'
|
|
|
|
|
2012-08-10 15:35:06 +00:00
|
|
|
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
|
2012-08-10 15:35:06 +00:00
|
|
|
end
|
2012-08-10 20:09:51 +00:00
|
|
|
|
|
|
|
default_task :server
|
2012-08-10 15:35:06 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|