lib/playmo/cli.rb in playmo-0.0.18 vs lib/playmo/cli.rb in playmo-0.1.0
- old
+ new
@@ -1,25 +1,47 @@
require 'thor/group'
+require 'thor/shell/color'
+require 'thor/shell/basic'
+trap("SIGINT") { print "\n"; exit! }
+
module Playmo
class Cli < Thor::Group
include Thor::Actions
- argument :application_name, :type => :string, :desc => "The name of the rails application"
- desc "Generates a new Rails application with Playmo'"
+ class_option 'dry-run', :aliases => "-d", :default => false, :desc => "Run without making any modifications on files"
+ class_option 'require', :aliases => "-r", :default => false, :desc => "Require gem that contains custom recipes"
+
+ # TODO: Use internal shell variable
+ def new_app
+ require_gem
- def run_playmo
- self.destination_root = application_name
- system "rails new #{application_name} -JT --skip-bundle"
-
- Playmo::Cookbook.instance.cook_recipes!(application_name)
+ color = Thor::Shell::Color.new
+ shell = Thor::Shell::Basic.new
+ shell.padding = 1
- system %Q{echo "gem 'therubyracer'" >> ./#{application_name}/Gemfile}
- system %Q{echo "gem 'playmo', :group => :development" >> ./#{application_name}/Gemfile}
+ shell.say("\n")
+
+ if application_name = shell.ask(color.set_color('Please enter the name of app you want to create:', :yellow, true))
+ Playmo::Cookbook.instance.cook_recipes!(application_name, options)
+ end
+
+ shell.say("\n")
+
system "cd #{application_name} && bundle install"
Event.events.fire :after_install
Event.events.fire :before_exit
+ end
+
+ private
+
+ def require_gem
+ return unless options[:require]
+ gem options[:require]
+ #load '/home/tanraya/sandbox/tanraya-playmo/lib/tanraya-playmo.rb'
+ #require 'rubygems'
+ #gem 'tanraya-playmo', :path => '../../../'
end
end
end
\ No newline at end of file