Sha256: 8affdebac61a407176c9729f6888b6e8e9c61506354f5ccfda29b13e99eee248

Contents?: true

Size: 707 Bytes

Versions: 3

Compression:

Stored size: 707 Bytes

Contents

# frozen_string_literal: true

module Dotcrypt::Cli::Commands::Exec
  def self.included(thor)
    thor.class_eval do
      include Dotcrypt::Cli::Commands::Globals

      desc "exec COMMAND", "exec command a command with dhall env"

      def exec(*command) = Handler.new(command, **options).call
    end
  end

  class Handler
    def initialize(command, **options)
      @command = command
      @options = options
    end

    def call
      exec(env, *@command)
    end

    private

    def env
      @env ||= Dotcrypt::Dhall.load_from(@options[:file]).then do |c|
        # TODO: validate variable names
        Dotcrypt::Flattener.call(c, separator: @options[:separator])
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dotcrypt-0.1.3 lib/dotcrypt/CLI/commands/exec.rb
dotcrypt-0.1.2 lib/dotcrypt/CLI/commands/exec.rb
dotcrypt-0.1.0 lib/dotcrypt/CLI/commands/exec.rb