From 2c0dc7fa63245d1a7539a8bb6e625a9de9426159 Mon Sep 17 00:00:00 2001 From: Sdogruyol Date: Sun, 3 Jul 2016 23:49:16 +0300 Subject: [PATCH] Read env from KEMAL_ENV instead of -e. Fixes #168 --- src/kemal/cli.cr | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/kemal/cli.cr b/src/kemal/cli.cr index 5319edb..c64bc2f 100644 --- a/src/kemal/cli.cr +++ b/src/kemal/cli.cr @@ -8,6 +8,7 @@ module Kemal @key_file = "" @cert_file = "" @config = Kemal.config + read_env parse configure_ssl end @@ -20,9 +21,6 @@ module Kemal opts.on("-p PORT", "--port PORT", "Port to listen for connections (defaults to 3000)") do |opt_port| @config.port = opt_port.to_i end - opts.on("-e ENV", "--environment ENV", "Environment [development, production] (defaults to development). Set `production` to boost performance") do |env| - @config.env = env - end opts.on("-s", "--ssl", "Enables SSL") do @ssl_enabled = true end @@ -49,5 +47,9 @@ module Kemal Kemal.config.ssl = ssl.context end end + + def read_env + @config.env = ENV.fetch("KEMAL_ENV", "development") + end end end