Sha256: 33a463a1e0e43939c781ad3c7956c92aafa2bb7644586b09dc782622d7d97ea7

Contents?: true

Size: 846 Bytes

Versions: 3

Compression:

Stored size: 846 Bytes

Contents

module Terraform
  module Binary
    # This module handles running the actual CLI commands
    module Command
      module_function

      # Raised when a command either fails or is invalid
      class CommandFailure < StandardError; end

      # Runs the given command with `Core::Kernel.system`
      # Example `run('sub-command -var "key=value" -machine-readable')`
      # @param [String] command the full sub-command to run (including cli arguments)
      # @return [String] true or {CommandFailure}
      def run(command)
        system("#{binary} #{command}") || (raise CommandFailure)
      end

      # Downloads, extracts and returns the path to the binary
      # @return [String] absolute path of the binary
      def binary
        e = Executable.new
        e.download
        e.extract
        e.binary
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
terraform-binary-1.0.1 lib/terraform/binary/command.rb
terraform-binary-0.1.1 lib/terraform/binary/command.rb
terraform-binary-0.1.0 lib/terraform/binary/command.rb