lib/playmo/cli.rb in playmo-0.1.2 vs lib/playmo/cli.rb in playmo-0.1.3
- old
+ new
@@ -1,36 +1,53 @@
require 'thor/group'
require 'thor/shell/color'
require 'thor/shell/basic'
-trap("SIGINT") { print "\n"; exit! }
+Signal.trap("INT") { puts; exit(1) }
module Playmo
class Cli < Thor::Group
include Thor::Actions
- 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"
+ 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"
+ class_option 'version',
+ :aliases => "-v",
+ :default => false,
+ :desc => "Show Playmo version"
+
# TODO: Use internal shell variable
def new_app
require_gem
color = Thor::Shell::Color.new
shell = Thor::Shell::Basic.new
shell.padding = 1
shell.say("\n")
- if application_name = shell.ask(color.set_color('Please enter the name of app you want to create:', :yellow, true))
+ question = color.set_color('Please enter the name of app you want to create:', :yellow, true)
+
+ if application_name = shell.ask(question)
Playmo::Cookbook.instance.cook_recipes!(application_name, options)
end
shell.say("\n")
- system "cd #{application_name} && bundle install"
+ system "cd #{application_name} && bundle install" unless options['dry-run']
- Event.events.fire :after_install
+ Event.events.fire :create_database
+ Event.events.fire :install
+ Event.events.fire :migrate_database
+ Event.events.fire :seed_database
Event.events.fire :before_exit
end
private
\ No newline at end of file