diff --git a/README.md b/README.md index a05d3c2..ee8e576 100644 --- a/README.md +++ b/README.md @@ -34,13 +34,13 @@ Or install it yourself as: Install gem into the system (e.g. using `gem install auxiliary_rails`) then: ```sh -auxiliary_rails APP_PATH +auxiliary_rails new APP_PATH ``` Or use `rails new` command specifying `--template` argument: ```sh -rails new APP_PATH --skip-action-cable --skip-coffee --skip-test --database=postgresql --template=https://raw.githubusercontent.com/ergoserv/auxiliary_rails/develop/templates/rails/template.rb +rails new APP_PATH --skip-action-cable --skip-coffee --skip-test --database=postgresql --template=https://raw.githubusercontent.com/ergoserv/auxiliary_rails/develop/templates/rails/elementary.rb ``` ### Generators diff --git a/lib/auxiliary_rails/cli.rb b/lib/auxiliary_rails/cli.rb index 9e6c7c4..85fdcdb 100644 --- a/lib/auxiliary_rails/cli.rb +++ b/lib/auxiliary_rails/cli.rb @@ -4,20 +4,33 @@ module AuxiliaryRails class CLI < Thor include Thor::Actions - RAILS_APP_TEMPLATE = - File.expand_path("#{__dir__}/../../templates/rails/template.rb") + TEMPLATES_DIR = + File.expand_path("#{__dir__}/../../templates/") - desc 'create_rails_app APP_PATH', 'Create Rails application from template' + desc 'new APP_PATH', 'Create Rails application from template' long_desc <<-LONGDESC - Creates Rails application from template: - #{RAILS_APP_TEMPLATE} + Create Rails application from the specified template. + Works like a wrapper for `rails new` command. - Example: auxiliary_rails create_rails_app ~/Code/weblog + Example: auxiliary_rails new ~/Code/weblog LONGDESC - def create_rails_app(app_path) + option :database, + default: 'postgresql', + type: :string + option :template_name, + default: 'elementary', + type: :string + def new(app_path) run "rails new #{app_path} " \ - '--skip-action-cable --skip-coffee --skip-test --database=postgresql ' \ - "--template=#{RAILS_APP_TEMPLATE}" + '--skip-action-cable --skip-coffee --skip-test ' \ + "--database=#{options[:database]} " \ + "--template=#{rails_template_path(options[:template_name])}" + end + + private + + def rails_template_path(template_name) + "#{TEMPLATES_DIR}/rails/#{template_name}.rb" end end end diff --git a/lib/auxiliary_rails/version.rb b/lib/auxiliary_rails/version.rb index ccf4ac1..f81ec2c 100644 --- a/lib/auxiliary_rails/version.rb +++ b/lib/auxiliary_rails/version.rb @@ -1,3 +1,3 @@ module AuxiliaryRails - VERSION = '0.1.3'.freeze + VERSION = '0.1.4'.freeze end diff --git a/templates/rails/template.rb b/templates/rails/elementary.rb similarity index 100% rename from templates/rails/template.rb rename to templates/rails/elementary.rb