Switch Resin to use Thor and have one main executable file with subcommands

This commit is contained in:
R. Tyler Croy 2013-02-18 07:37:30 -08:00
parent 0a670c1cf4
commit 32b2c519ce
5 changed files with 26 additions and 19 deletions

6
bin/resin Executable file
View File

@ -0,0 +1,6 @@
#!/usr/env/bin ruby
require 'rubygems'
require 'resin/cli'
Resin::CLI.start

View File

@ -1,6 +0,0 @@
#!/usr/bin/env ruby
require 'rubygems'
require 'resin/compiler'
Resin::Compiler.run

View File

@ -1,12 +0,0 @@
#!/usr/bin/env ruby
begin
require 'resin/app'
rescue LoadError => e
require 'rubygems'
path = File.expand_path '../../lib', __FILE__
$:.unshift(path) if File.directory?(path) && !$:.include?(path)
require 'resin/app'
end
Resin::Server.run!

19
lib/resin/cli.rb Normal file
View File

@ -0,0 +1,19 @@
require 'thor'
module Resin
class CLI < Thor
desc 'start', 'Run the current Resin application'
def start
require 'sinatra/base'
require 'sinatra/resin'
Sinatra::Application.run!
end
desc 'compile', 'Compile all the Amber and JavaScripts together'
def compile
require 'resin/compiler'
Resin::Compiler.run
end
end
end

View File

@ -11,7 +11,7 @@ spec = Gem::Specification.new do |s|
s.files = Dir['bin/*'] + Dir['lib/**/*.rb'] + Dir['lib/**/*.haml'] + Dir['amber/css/*'] +
Dir['amber/js/**/*'] + Dir['amber/st/**/*.st'] + Dir['amber/images/*'] + ['amber/bin/amberc', 'amber/bin/nodecompile.js']
s.bindir = 'bin'
s.executables = ['runresin', 'resin-compile']
s.executables = ['resin']
s.has_rdoc = true
s.extra_rdoc_files = ["README.markdown"]