Class: Puppet::Util::CommandLine::NilSubcommand Private

Inherits:
Object
  • Object
show all
Includes:
Puppet::Util::Colors
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.

Direct Known Subclasses

UnknownSubcommand

Constant Summary

Constants included from Puppet::Util::Colors

Puppet::Util::Colors::BG_BLUE, Puppet::Util::Colors::BG_CYAN, Puppet::Util::Colors::BG_GREEN, Puppet::Util::Colors::BG_HBLUE, Puppet::Util::Colors::BG_HCYAN, Puppet::Util::Colors::BG_HGREEN, Puppet::Util::Colors::BG_HMAGENTA, Puppet::Util::Colors::BG_HRED, Puppet::Util::Colors::BG_HWHITE, Puppet::Util::Colors::BG_HYELLOW, Puppet::Util::Colors::BG_MAGENTA, Puppet::Util::Colors::BG_RED, Puppet::Util::Colors::BG_WHITE, Puppet::Util::Colors::BG_YELLOW, Puppet::Util::Colors::BLACK, Puppet::Util::Colors::BLUE, Puppet::Util::Colors::CYAN, Puppet::Util::Colors::Colormap, Puppet::Util::Colors::GREEN, Puppet::Util::Colors::HBLACK, Puppet::Util::Colors::HBLUE, Puppet::Util::Colors::HCYAN, Puppet::Util::Colors::HGREEN, Puppet::Util::Colors::HMAGENTA, Puppet::Util::Colors::HRED, Puppet::Util::Colors::HWHITE, Puppet::Util::Colors::HYELLOW, Puppet::Util::Colors::MAGENTA, Puppet::Util::Colors::RED, Puppet::Util::Colors::RESET, Puppet::Util::Colors::WHITE, Puppet::Util::Colors::YELLOW

Instance Method Summary collapse

Methods included from Puppet::Util::Colors

#colorize, #console_color, #html_color

Constructor Details

#initialize(command_line) ⇒ NilSubcommand

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 NilSubcommand.



152
153
154
# File 'lib/puppet/util/command_line.rb', line 152

def initialize(command_line)
  @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.



156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/puppet/util/command_line.rb', line 156

def run
  args = @command_line.args
  if args.include? "--version" or args.include? "-V"
    puts Puppet.version
  elsif @command_line.subcommand_name.nil? && args.count > 0
    # If the subcommand is truly nil and there is an arg, it's an option; print out the invalid option message
    puts colorize(:hred, _("Error: Could not parse application options: invalid option: %{opt}") % { opt: args[0] })
    exit 1
  else
    puts _("See 'puppet help' for help on available puppet subcommands")
  end
end