Module: Hanami::CLI::Commands::App::Command::Environment Private
- Defined in:
- lib/hanami/cli/commands/app/command.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Overloads #call to ensure an appropriate
HANAMI_ENV environment variable is set.
Uses an --env option if provided, then falls back to an already-set HANAMI_ENV
environment variable, and defaults to "development" in the absence of both.
Class Method Summary collapse
- .prepended(klass) ⇒ Object private
Instance Method Summary collapse
- #call(*args, **opts) ⇒ Object private
Class Method Details
.prepended(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.
28 29 30 31 32 33 34 |
# File 'lib/hanami/cli/commands/app/command.rb', line 28 def self.prepended(klass) # This module is included each time the class is inherited from # Without this check, the --env option is duplicated each time unless klass..map(&:name).include?(:env) klass.option :env, desc: "App environment (development, test, production)", aliases: ["e"] end end |
Instance Method Details
#call(*args, **opts) ⇒ 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.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/hanami/cli/commands/app/command.rb', line 38 def call(*args, **opts) env = opts[:env] hanami_env = env ? env.to_s : ENV.fetch("HANAMI_ENV", "development") ENV["HANAMI_ENV"] = hanami_env Hanami::Env.load super rescue FileAlreadyExistsError => error err.puts(error.) exit(1) end |