lib/hanami/cli_sub_commands/generate.rb in hanami-1.0.0.beta2 vs lib/hanami/cli_sub_commands/generate.rb in hanami-1.0.0.beta3
- old
+ new
@@ -16,12 +16,10 @@
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'
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'.
@@ -35,10 +33,12 @@
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.'
+ # @since 0.6.0
+ # @api private
def actions(application_name = nil, controller_and_action_name)
if Hanami::Environment.new(options).container? && application_name.nil?
msg = "ERROR: \"hanami generate action\" was called with arguments [\"#{controller_and_action_name}\"]\n" \
"Usage: \"hanami generate action APPLICATION_NAME CONTROLLER_NAME#ACTION_NAME\""
fail Error, msg
@@ -55,10 +55,11 @@
long_desc <<-EOS
`hanami generate migration` will generate an empty migration file.
> $ hanami generate migration do_something
EOS
+ # @api private
def migration(name)
if options[:help]
invoke :help, ['migration']
else
require 'hanami/commands/generate/migration'
@@ -76,10 +77,11 @@
> $ hanami generate model vehicles/car
EOS
method_option :test, desc: 'Defines the testing Framework to be used. Default is defined through your .hanamirc file.'
method_option :skip_migration, desc: 'Skips the generation of a migration to create the model\'s table', default: false, type: :boolean
+ # @api private
def model(name)
if options[:help]
invoke :help, ['model']
else
require 'hanami/commands/generate/model'
@@ -95,10 +97,11 @@
> $ 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
+ # @api private
def mailer(name)
if options[:help]
invoke :help, ['mailer']
else
Hanami::Commands::Generate::Mailer.new(options, name).start
@@ -114,10 +117,11 @@
> $ hanami generate app admin
> $ hanami generate app reporting --application_base_url=/reports
EOS
method_option :application_base_url, desc: 'Base URL for the new app. If missing, then it is inferred from APPLICATION_NAME'
+ # @api private
def app(application_name)
if options[:help]
invoke :help, ['app']
else
require 'hanami/commands/generate/app'
@@ -130,9 +134,10 @@
`hanami generate secret` prints a new secret for a given app
> $ hanami generate secret web
EOS
+ # @api private
def secret(application_name = nil)
if options[:help]
invoke :help, ['secret']
else
require 'hanami/commands/generate/secret_token'