lib/daiku/cli.rb in daiku-0.0.12 vs lib/daiku/cli.rb in daiku-0.1.0
- old
+ new
@@ -1,84 +1,83 @@
# encoding: utf-8
require 'thor'
module Daiku
- class CLI < Thor
- include Thor::Actions
+ class CLI < ::Thor
+ include ::Thor::Actions
+ class_option :version, type: :boolean
def self.source_root
File.expand_path('../', __FILE__)
end
desc "new APP", "Generate a new application with daiku"
method_option :port, required: true, aliases: '-p', type: :numeric, desc: 'Port this app should run on locally.'
- method_option :ruby_version, default: '2.1.2', desc: 'Specify the version of ruby this project should use.'
- method_option :models, default: 'datamapper', aliases: '-m', desc: 'Choose the data modeling tool this project uses.', enum: ['datamapper', 'none']
- method_option :assets, default: 'grunt', aliases: '-a', desc: 'Choose the assets workflow this project uses.', enum: ['grunt', 'none']
- method_option :'honeybadger-private-key', desc: "Honeybadger Private API Key"
- method_option :'honeybadger-public-key', desc: "Honeybadger Private API Key"
- method_option :'no-newrelic', type: :boolean, desc: "Don't use New Relic."
- method_option :'with-vcr', type: :boolean, desc: "Include `vcr` in this project's TDD stack."
- method_option :'with-sidekiq', type: :boolean, desc: "Set this project up to use `sidekiq` for background processing."
+ method_option :ruby, default: '2.1.5', desc: 'Specify the version of ruby this project should use.'
+ method_option :node, default: 'v0.10.33', desc: 'Specify the version of node this project should use.'
+ method_option :assets, aliases: '-a', desc: 'Choose the assets workflow this project uses.', enum: Daiku::Plugins.plugin_names('assets')
+ method_option :errors, aliases: '-e', desc: 'Choose the error reporting lib this project uses.', enum: Daiku::Plugins.plugin_names('errors')
+ method_option :jobs, aliases: '-j', desc: 'Choose the background jobs lib this project uses.', enum: Daiku::Plugins.plugin_names('jobs')
+ method_option :models, aliases: '-m', desc: 'Choose the data modeling lib this project uses.', enum: Daiku::Plugins.plugin_names('models')
+ method_option :monitors, aliases: '-M', desc: 'Choose the monitoring lib this project uses.', enum: Daiku::Plugins.plugin_names('monitors')
+ method_option :vcr, type: :boolean, desc: "Include `vcr` in this project's BDD stack?", default: false
+ method_option :sql, type: :boolean, desc: "SQL or No-SQL? If SQL, assumes postgresql", default: true
def new(app)
- @app = app
- @port = options[:port]
- @ruby_version = options[:ruby_version]
+ @app = app
+ @port = options[:port]
+ @ruby = options[:ruby]
@models = options[:models]
@assets = options[:assets]
- @honeybadger_private_key = options[:'honeybadger-private-key']
- @honeybadger_public_key = options[:'honeybadger-public-key']
- @no_newrelic = options[:'no-newrelic']
- @with_vcr = options[:'with-vcr']
- @with_sidekiq = options[:'with-sidekiq']
+ @jobs = options[:jobs]
- case @models
- when 'datamapper'
- @datamapper = true
- when 'none'
- @datamapper = false
- end
-
- case @assets
- when 'grunt'
- @grunt = true
- when 'none'
- @grunt = false
- end
-
# do the dew
say "Generating #{app} app..."
directory('_app', app)
chmod("#{app}/bin/console", 'a+x')
- template("_templates/#{@models}.rb.tt", "#{app}/config/#{@models}.rb")
- copy_file('_templates/db_helper.rb', "#{app}/spec/db_helper.rb") if @datamapper
- if @grunt
- directory('_grunt', app)
+ if @assets
+ invoke plugins[@assets][:class].cli, [@app], options
end
- if @with_vcr
- copy_file('_templates/vcr_helper.rb', "#{app}/spec/vcr_helper.rb")
- empty_directory("#{app}/spec/_cassettes")
- create_file("#{app}/spec/_cassettes/.gitkeep", "")
+ if @errors
+ invoke plugins[@errors][:class].cli, [@app], options
end
- if @with_sidekiq
- template('_templates/sidekiq.rb.tt', "#{app}/config/sidekiq.rb")
- empty_directory("#{app}/lib/jobs")
- create_file("#{app}/lib/jobs/.gitkeep", "")
- append_to_file("#{app}/lib/boot.rb") do
- "# jobs\n" +
- "require File.join($app_root, 'config/sidekiq')"
- end
+ if @jobs
+ invoke plugins[@jobs][:class].cli, [@app], options
end
+ if @models
+ invoke plugins[@models][:class].cli, [@app], options
+ end
+
+ if @monitors
+ invoke plugins[@monitors][:class].cli, [@app], options
+ end
+
+ if options[:sql]
+ invoke plugins['database-sql'][:class].cli, [@app], options
+ else
+ say_status 'skipped', "--no-sql option is not supported yet", :yellow
+ end
+
+ if options[:vcr]
+ invoke plugins['vcr'][:class].cli, [@app], options
+ end
+
say "Done!"
end
- desc "version", "Prints version number"
+ desc "version", "Show the daiku version"
def version
say "Daiku v#{Daiku::VERSION}"
+ end
+ default_task :version
+
+ no_tasks do
+ def plugins
+ Daiku::Plugins.register_plugins
+ end
end
end
end