Class: Puppet::Util::CommandLine::ApplicationSubcommand Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/command_line.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(subcommand_name, command_line) ⇒ ApplicationSubcommand

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ApplicationSubcommand.



115
116
117
118
# File 'lib/puppet/util/command_line.rb', line 115

def initialize(subcommand_name, command_line)
  @subcommand_name = subcommand_name
  @command_line = command_line
end

Instance Method Details

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/puppet/util/command_line.rb', line 120

def run
  # For most applications, we want to be able to load code from the modulepath,
  # such as apply, describe, resource, and faces.
  # For agent, we only want to load pluginsync'ed code from libdir.
  # For master, we shouldn't ever be loading per-enviroment code into the master's
  # ruby process, but that requires fixing (#17210, #12173, #8750). So for now
  # we try to restrict to only code that can be autoloaded from the node's
  # environment.
  if @subcommand_name != 'master' and @subcommand_name != 'agent'
    Puppet.lookup(:environments).get(Puppet[:environment]).each_plugin_directory do |dir|
      $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
    end
  end

  app = Puppet::Application.find(@subcommand_name).new(@command_line)
  Puppet::Plugins.on_application_initialization(:application_object => @command_line)

  app.run
end