Sha256: ab15c3e9a0aae758b257c4fee207c4a3fa093f7cf17be2e5c50c6bf9534af6d3

Contents?: true

Size: 878 Bytes

Versions: 6

Compression:

Stored size: 878 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) }
      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

6 entries across 6 versions & 1 rubygems

Version Path
roro-0.3.30 lib/roro/cli/generate/generate_environments.rb
roro-0.3.28 lib/roro/cli/generate/generate_environments.rb
roro-0.3.27 lib/roro/cli/generate/generate_environments.rb
roro-0.3.25 lib/roro/cli/generate/generate_environments.rb
roro-0.3.24 lib/roro/cli/generate/generate_environments.rb
roro-0.3.23 lib/roro/cli/generate/generate_environments.rb