Sha256: 673ab32784c7bfcbbcddab8358dfec9bf4e40c484d20ca19b4a8c500933da7c0

Contents?: true

Size: 703 Bytes

Versions: 1

Compression:

Stored size: 703 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 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::Jsonnet.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

1 entries across 1 versions & 1 rubygems

Version Path
dotcrypt-0.2.0 lib/dotcrypt/CLI/commands/exec.rb