Class: Hanami::CLI::Commands::App::Command
- Inherits:
-
Hanami::CLI::Command
- Object
- Dry::CLI::Command
- Hanami::CLI::Command
- Hanami::CLI::Commands::App::Command
- Defined in:
- lib/hanami/cli/commands/app/command.rb
Overview
Base class for hanami
CLI commands intended to be executed within an existing Hanami
app.
Direct Known Subclasses
Assets::Command, Console, DB::Create, DB::CreateMigration, DB::Drop, DB::Migrate, DB::Reset, DB::Rollback, DB::SampleData, DB::Seed, DB::Setup, DB::Structure::Dump, DB::Version, Dev, Generate::Action, Generate::Part, Generate::Slice, Generate::View, Install, Version
Defined Under Namespace
Modules: Environment
Constant Summary collapse
- ACTION_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"."
Class Method Summary collapse
- .inherited(klass) ⇒ Object private
Instance Method Summary collapse
-
#app ⇒ Hanami::App
Returns the Hanami app class.
-
#database ⇒ Object
private
This is NOT AVAILABLE as of the 2.0.0 release.
-
#database_config ⇒ Object
private
This is NOT AVAILABLE as of the 2.0.0 release.
-
#measure(desc) ⇒ Object
Executes a given block and prints string to the
out
stream with details of the time taken to execute. -
#run_command(klass, *args) ⇒ Object
Runs another CLI command via its command class.
Methods inherited from Hanami::CLI::Command
Constructor Details
This class inherits a constructor from Hanami::CLI::Command
Class Method Details
.inherited(klass) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 49 |
# File 'lib/hanami/cli/commands/app/command.rb', line 46 def self.inherited(klass) super klass.prepend(Environment) end |
Instance Method Details
#app ⇒ Hanami::App
Returns the Hanami app class.
59 60 61 62 63 64 65 |
# File 'lib/hanami/cli/commands/app/command.rb', line 59 def app @app ||= begin require "hanami/prepare" Hanami.app end end |
#database ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This is NOT AVAILABLE as of the 2.0.0 release.
118 119 120 |
# File 'lib/hanami/cli/commands/app/command.rb', line 118 def database @database ||= Commands::App::DB::Utils::Database[app] end |
#database_config ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This is NOT AVAILABLE as of the 2.0.0 release.
125 126 127 |
# File 'lib/hanami/cli/commands/app/command.rb', line 125 def database_config database.config end |
#measure(desc) ⇒ Object
Executes a given block and prints string to the out
stream with details of the time
taken to execute.
If the block returns a falsey value, then a failure message is printed.
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/hanami/cli/commands/app/command.rb', line 103 def measure(desc) start = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = yield stop = Process.clock_gettime(Process::CLOCK_MONOTONIC) if result out.puts "=> #{desc} in #{(stop - start).round(4)}s" else out.puts "!!! => #{desc.inspect} FAILED" end end |