# class Puppet::Util::CommandLine::ApplicationSubcommand

@api private

### Public Class Methods

new(subcommand_name, command_line) click to toggle source

    # File lib/puppet/util/command_line.rb, line 110
    def initialize(subcommand_name, command_line)
      @subcommand_name = subcommand_name
      @command_line = command_line
    end

### Public Instance Methods

run() click to toggle source

    # File lib/puppet/util/command_line.rb, line 115
    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::Node::Environment.new.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