lib/hanami/cli/commands/app/command.rb in hanami-cli-2.2.0.beta2 vs lib/hanami/cli/commands/app/command.rb in hanami-cli-2.2.0.rc1
- old
+ new
@@ -16,29 +16,35 @@
class Command < Hanami::CLI::Command
# @since 2.0.0
# @api private
ACTION_SEPARATOR = "." # TODO: rename to container key separator
- # Overloads {Hanami::CLI::Commands::App::Command#call} to ensure an appropriate `HANAMI_ENV`
- # environment variable is set.
+ # Overloads {Hanami::CLI::Commands::App::Command#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.
#
# @since 2.0.0
# @api private
module Environment
+ # @since 2.2.0
+ # @api private
+ def self.prepended(klass)
+ klass.option :env, desc: "App environment (development, test, production)", aliases: ["e"]
+ end
+
# @since 2.0.0
# @api private
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(*args, **opts)
+ super
end
end
# @since 2.0.0
# @api private