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
11 def initialize(name, executable, resolver, executor, options = {})
12   @name = name
13   @executable = executable
14   @resolver = resolver
15   @executor = executor
16   @options = options
17 end

Public Instance Methods

execute(*args) click to toggle source

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

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