lib/tiny-rails/cli.rb in tiny-rails-0.0.1 vs lib/tiny-rails/cli.rb in tiny-rails-0.0.2

- old
+ new

@@ -1,50 +1,25 @@ require 'thor' require 'thor/group' +require 'tiny-rails/actions' +require 'tiny-rails/commands/new' +require 'tiny-rails/commands/add' + module TinyRails - class CLI < Thor::Group + class CLI < Thor include Thor::Actions - argument :app_path, :required => true - - def self.source_root - "#{File.expand_path('../../../templates', __FILE__)}/" + desc 'new APP_PATH', 'Creates a new tiny Rails application' + method_option :addons, :type => :array, :aliases => '-a', :default => [] + def new(app_path) + Commands::New.start([app_path]) + add(options[:addons]) unless options[:addons].empty? end - def self.banner - "tiny-rails #{self.arguments.map(&:usage).join(' ')} [options]" - end - - def self.templates - @templates ||= %w( - application.coffee - application.scss - boot.rb - config.ru - Gemfile - index.html.haml - migrate - models.rb - server - tiny_rails_controller.rb - .gitignore - ) - end - - def self.executables - @executables ||= %w( - migrate - server - ) - end - - def scaffold - self.class.templates.each do |template| - template(template, "#{app_path}/#{template}") - end - self.class.executables.each do |script| - chmod "#{app_path}/#{script}", 0755 - end + desc 'add [addons]', 'Configures addons on a generated tiny Rails application' + def add(addons = []) + addons = Array(addons) + Commands::Add.start(addons) end end end