class Puppet::Provider::Command

A command that can be executed on the system

Attributes

executable[R]
name[R]

Public Class Methods

new(name, executable, resolver, executor, options = {}) click to toggle source

@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)

# File lib/puppet/provider/command.rb, line 11
def initialize(name, executable, resolver, executor, options = {})
  @name = name
  @executable = executable
  @resolver = resolver
  @executor = executor
  @options = options
end

Public Instance Methods

execute(*args) click to toggle source

@param [Array<String>] Any command line arguments to pass to the executable @returns The output from the command

# File lib/puppet/provider/command.rb, line 21
def execute(*args)
  resolved_executable = @resolver.which(@executable) or raise Puppet::Error, "Command #{@name} is missing"
  @executor.execute([resolved_executable] + args, @options)
end