Sha256: c20a4217590041bdd92e7c8c3af798d587a22ba7e57b3bee6e7b04d895c8fabf

Contents?: true

Size: 1.12 KB

Versions: 20

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true
# A command that can be executed on the system
class Puppet::Provider::Command
  attr_reader :executable
  attr_reader :name

  # @param [String] name A way of referencing the name
  # @param [String] executable The path to the executable file
  # @param resolver An object for resolving the executable to an absolute path (usually Puppet::Util)
  # @param executor An object for performing the actual execution of the command (usually Puppet::Util::Execution)
  # @param [Hash] options Extra options to be used when executing (see Puppet::Util::Execution#execute)
  def initialize(name, executable, resolver, executor, options = {})
    @name = name
    @executable = executable
    @resolver = resolver
    @executor = executor
    @options = options
  end

  # @param args [Array<String>] Any command line arguments to pass to the executable
  # @return The output from the command
  def execute(*args)
    resolved_executable = @resolver.which(@executable) or raise Puppet::MissingCommand, _("Command %{name} is missing") % { name: @name }
    @executor.execute([resolved_executable] + args, @options)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/provider/command.rb
puppet-8.3.0-x86-mingw32 lib/puppet/provider/command.rb
puppet-8.3.0-x64-mingw32 lib/puppet/provider/command.rb
puppet-8.3.0-universal-darwin lib/puppet/provider/command.rb
puppet-8.3.1 lib/puppet/provider/command.rb
puppet-8.3.1-x86-mingw32 lib/puppet/provider/command.rb
puppet-8.3.1-x64-mingw32 lib/puppet/provider/command.rb
puppet-8.3.1-universal-darwin lib/puppet/provider/command.rb
puppet-8.2.0 lib/puppet/provider/command.rb
puppet-8.2.0-x86-mingw32 lib/puppet/provider/command.rb
puppet-8.2.0-x64-mingw32 lib/puppet/provider/command.rb
puppet-8.2.0-universal-darwin lib/puppet/provider/command.rb
puppet-8.1.0 lib/puppet/provider/command.rb
puppet-8.1.0-x86-mingw32 lib/puppet/provider/command.rb
puppet-8.1.0-x64-mingw32 lib/puppet/provider/command.rb
puppet-8.1.0-universal-darwin lib/puppet/provider/command.rb
puppet-8.0.1 lib/puppet/provider/command.rb
puppet-8.0.1-x86-mingw32 lib/puppet/provider/command.rb
puppet-8.0.1-x64-mingw32 lib/puppet/provider/command.rb
puppet-8.0.1-universal-darwin lib/puppet/provider/command.rb