Sha256: 05ca2f2af474bfd72831ec34dc1ca975e6b609f6d6db5d7b4d9a5a11fd54bd32

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 Bytes

Contents

# frozen_string_literal: true

module Roro
  class CLI < Thor
    desc 'generate:environments', 'Generate environment files and keys'
    map 'generate:environments'  => 'generate_environments'

    def generate_environments(*args)
      if args.last.is_a?(Hash)
        hash = args.pop
      end
      default_environments = Roro::CLI.roro_environments
      mise = Roro::CLI.mise
      environments = args.empty? ? default_environments : args
      containers = Dir.glob("./#{mise}/containers/*").select { |f| File.directory?(f) }
      create_file "./#{mise}/env/.keep", ''
      environments.each do |env|
        content = hash&.dig(env.to_sym)&.each&.map {|k,v| "#{k}=#{v[:value]}"}&.join("\n") || 'SOME_KEY=some_value'
        create_file "./#{mise}/env/#{env}.env", content
        containers.each do |container|
          create_file "#{container}/env/#{env}.env", content
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roro-0.3.33 lib/roro/cli/generate/generate_environments.rb