Class: Puppet::Util::CommandLine

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

Overview

This is the main entry point for all puppet applications / faces; it is basically where the bootstrapping process / lifecycle of an app begins.

Defined Under Namespace

Classes: ApplicationSubcommand, ExternalSubcommand, NilSubcommand, UnknownSubcommand

Constant Summary

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Limits

#setpriority

Class Method Details

.available_subcommandsObject

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.

Deprecated.


64
65
66
67
# File 'lib/puppet/util/command_line.rb', line 64

def self.available_subcommands
  Puppet.deprecation_warning('Puppet::Util::CommandLine.available_subcommands is deprecated; please use Puppet::Application.available_application_names instead.')
  Puppet::Application.available_application_names
end

Instance Method Details

#argsArray<String>

Returns the command line arguments being passed to the subcommand



52
53
54
55
56
57
58
59
60
# File 'lib/puppet/util/command_line.rb', line 52

def args
  return @argv if @command != 'puppet'

  if subcommand_name.nil?
    @argv
  else
    @argv[1..-1]
  end
end

#available_subcommandsObject

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.

Deprecated.

available_subcommands was previously an instance method, not a class method, and we have an unknown number of user-implemented applications that depend on that behaviour. Forwarding allows us to preserve a backward compatible API. --daniel 2011-04-11



75
76
77
78
# File 'lib/puppet/util/command_line.rb', line 75

def available_subcommands
  Puppet.deprecation_warning('Puppet::Util::CommandLine#available_subcommands is deprecated; please use Puppet::Application.available_application_names instead.')
  Puppet::Application.available_application_names
end

#external_subcommandObject

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.



96
97
98
# File 'lib/puppet/util/command_line.rb', line 96

def external_subcommand
  Puppet::Util.which("puppet-#{subcommand_name}")
end

#subcommand_nameString

Returns name of the subcommand is being executed



40
41
42
43
44
45
46
47
48
# File 'lib/puppet/util/command_line.rb', line 40

def subcommand_name
  return @command if @command != 'puppet'

  if @argv.first =~ OPTION_OR_MANIFEST_FILE
    nil
  else
    @argv.first
  end
end