lib/hanami/cli_sub_commands/generate.rb in hanami-0.7.3 vs lib/hanami/cli_sub_commands/generate.rb in hanami-0.8.0
- old
+ new
@@ -11,17 +11,18 @@
# `bundle exec hanami generate`
#
# @since 0.6.0
# @api private
class Generate < Thor
+ extend CliBase
include Thor::Actions
namespace :generate
# @since 0.6.0
# @api private
- desc 'action APPLICATION_NAME CONTROLLER_NAME#ACTION_NAME', 'generate a hanami action'
+ desc 'action APPLICATION_NAME CONTROLLER_NAME#ACTION_NAME', 'Generate a hanami action'
long_desc <<-EOS
`hanami generate action` generates an an action, view and template along with specs and a route.
For Application architecture the application name is 'app'. For Container architecture the default application is called 'web'.
@@ -29,11 +30,11 @@
> $ hanami generate action other-app cars#index
> $ hanami generate action web cars#create --method=post
EOS
- method_option :method, desc: "The HTTP method to be used for the generated route. Must be one of (#{Hanami::Routing::Route::VALID_HTTP_VERBS.join('/')})", default: Hanami::Commands::Generate::Action::DEFAULT_HTTP_METHOD
+ method_option :method, desc: "The HTTP method to be used for the generated route. Default is #{Hanami::Commands::Generate::Action::DEFAULT_HTTP_METHOD}. Must be one of (#{Hanami::Routing::Route::VALID_HTTP_VERBS.join('/')})"
method_option :url, desc: 'Relative URL for action, will be used for the route', default: nil
method_option :test, desc: 'Defines the testing Framework to be used. Default is defined through your .hanamirc file.'
method_option :skip_view, desc: 'Skip the generation of the view. Also skips template generation.', default: false, type: :boolean
method_option :template, desc: 'Extension to be used for the generated template. Default is defined through your .hanamirc file.'
def actions(application_name = nil, controller_and_action_name)
@@ -48,11 +49,11 @@
else
Hanami::Commands::Generate::Action.new(options, application_name, controller_and_action_name).start
end
end
- desc 'migration NAME', 'generate a migration'
+ desc 'migration NAME', 'Generate a migration'
long_desc <<-EOS
`hanami generate migration` will generate an empty migration file.
> $ hanami generate migration do_something
EOS
@@ -63,11 +64,11 @@
require 'hanami/commands/generate/migration'
Hanami::Commands::Generate::Migration.new(options, name).start
end
end
- desc 'model NAME', 'generate an entity'
+ desc 'model NAME', 'Generate an entity'
long_desc <<-EOS
`hanami generate model` will generate an entity along with repository
and corresponding tests. The name of the model can contain slashes to
indicate module names.
@@ -83,28 +84,28 @@
require 'hanami/commands/generate/model'
Hanami::Commands::Generate::Model.new(options, name).start
end
end
- desc 'mailer NAME', 'generate a mailer'
+ desc 'mailer NAME', 'Generate a mailer'
long_desc <<-EOS
`hanami generate mailer` will generate an empty mailer, along with templates and specs.
> $ hanami generate mailer forgot_password
> $ hanami generate mailer forgot_password --to "'log@bookshelf.com'" --from "'support@bookshelf.com'" --subject "'New Password'"
EOS
- method_option :to, desc: 'sender email', default: Hanami::Commands::Generate::Mailer::DEFAULT_TO
- method_option :from, desc: 'sendee email', default: Hanami::Commands::Generate::Mailer::DEFAULT_FROM
- method_option :subject, desc: 'email subject', default: Hanami::Commands::Generate::Mailer::DEFAULT_SUBJECT
+ method_option :to, desc: 'Sender email', default: Hanami::Commands::Generate::Mailer::DEFAULT_TO
+ method_option :from, desc: 'Sendee email', default: Hanami::Commands::Generate::Mailer::DEFAULT_FROM
+ method_option :subject, desc: 'Email subject', default: Hanami::Commands::Generate::Mailer::DEFAULT_SUBJECT
def mailer(name)
if options[:help]
invoke :help, ['mailer']
else
Hanami::Commands::Generate::Mailer.new(options, name).start
end
end
- desc 'app APPLICATION_NAME', 'generate an app'
+ desc 'app APPLICATION_NAME', 'Generate an app'
long_desc <<-EOS
`hanami generate app` creates a new app inside the 'apps' directory.
It can only be called for hanami applications with container architecture.