Sha256: d8dbd8dc5f9638393c4bcb34dc58b721c5814ed2c5081c283ea349c6d650f5c1

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

module Envify
  class Cli < Thor
    def self.exit_on_failure?
      true
    end

    class_option :destination, aliases: '-d',
                               desc: 'Specify destination to be used for generating .env file (staging -> env.staging)'

    method_options alias: 'g'
    desc 'generate', 'Create .env by evaluating .env.erb (or .env.staging.erb -> .env.staging when using -d staging)'
    def generate
      if destination = options[:destination]
        env_template_path = ".env.#{destination}.erb"
        env_path          = ".env.#{destination}"
      else
        env_template_path = '.env.erb'
        env_path          = '.env'
      end

      File.write(env_path, ERB.new(File.read(env_template_path), trim_mode: '>').result, perm: 0o600)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
envify-0.1.0 lib/envify/cli.rb