Skip to content

Commit

Permalink
Rename CLI comman create_rails_app to new
Browse files Browse the repository at this point in the history
* add `database` and `template_name` options
  • Loading branch information
stgeneral committed May 12, 2019
1 parent b1ee8b9 commit 9de40ba
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 22 additions & 9 deletions lib/auxiliary_rails/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/auxiliary_rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module AuxiliaryRails
VERSION = '0.1.3'.freeze
VERSION = '0.1.4'.freeze
end
File renamed without changes.

0 comments on commit 9de40ba

Please sign in to comment.