diff --git a/bin/mrsk b/bin/mrsk index dac9af62..1d85ee6c 100755 --- a/bin/mrsk +++ b/bin/mrsk @@ -3,7 +3,6 @@ # Prevent failures from being reported twice. Thread.report_on_exception = false -require "dotenv/load" require "mrsk" begin diff --git a/lib/mrsk/cli/base.rb b/lib/mrsk/cli/base.rb index 17a6c4dd..1e28e956 100644 --- a/lib/mrsk/cli/base.rb +++ b/lib/mrsk/cli/base.rb @@ -1,4 +1,5 @@ require "thor" +require "dotenv" require "mrsk/sshkit_with_ext" module Mrsk::Cli @@ -21,10 +22,19 @@ module Mrsk::Cli def initialize(*) super + load_envs initialize_commander(options) end private + def load_envs + if destination = options[:destination] + Dotenv.load(".env.#{destination}", ".env") + else + Dotenv.load(".env") + end + end + def initialize_commander(options) MRSK.tap do |commander| commander.config_file = Pathname.new(File.expand_path(options[:config_file]))