class PuppetDebugger::InputResponders::Commands

Constants

COMMAND_GROUP
COMMAND_WORDS
SUMMARY

Public Class Methods

command_list() click to toggle source
# File lib/plugins/puppet-debugger/input_responders/commands.rb, line 52
def self.command_list
  command_output.map { |f| f[:words] }.flatten
end
command_list_regex() click to toggle source
# File lib/plugins/puppet-debugger/input_responders/commands.rb, line 47
def self.command_list_regex
  out = command_list.map { |n| "^#{n}" }.join('|')
  /#{out}/
end
command_output() click to toggle source
# File lib/plugins/puppet-debugger/input_responders/commands.rb, line 56
def self.command_output
  plugins.map(&:details)
end
plugin_from_command(name) click to toggle source

@param name [String] - the name of the command that is associated with a plugin @return [PuppetDebugger::InputResponders::InputResponderPlugin]

# File lib/plugins/puppet-debugger/input_responders/commands.rb, line 69
def self.plugin_from_command(name)
  plug = plugins.find { |p| p::COMMAND_WORDS.include?(name) }
  raise PuppetDebugger::Exception::InvalidCommand.new(message: "invalid command #{name}") unless plug

  plug
end
plugins() click to toggle source
# File lib/plugins/puppet-debugger/input_responders/commands.rb, line 60
def self.plugins
  debug_plugins = Pluginator.find('puppet-debugger')
  debug_plugins['input_responders']
rescue NoMethodError
  raise PuppetDebugger::Exception::InvalidCommand.new(message: 'Unsupported gem version.  Please update with: gem update --system')
end

Public Instance Methods

command_groups() click to toggle source
# File lib/plugins/puppet-debugger/input_responders/commands.rb, line 33
def command_groups
  unless @command_groups
    @command_groups = {}
    self.class.command_output.each do |item|
      if @command_groups[item[:group]]
        @command_groups[item[:group]].merge!(item[:words].first => item[:summary])
      else
        @command_groups[item[:group]] = { item[:words].first => item[:summary] }
      end
    end
  end
  @command_groups
end
commands_list() click to toggle source
# File lib/plugins/puppet-debugger/input_responders/commands.rb, line 15
def commands_list
  unless @commands_list
    @commands_list = ''
    command_groups.sort.each do |command_group|
      group_name = command_group[0].to_s.capitalize.bold
      commands = command_group[1]
      @commands_list += ' ' + group_name + "\n"
      commands.sort.each do |command|
        command_name = command[0]
        command_description = command[1]
        @commands_list += format("   %-20s %s\n", command_name, command_description)
      end
      @commands_list += "\n"
    end
  end
  @commands_list
end
run(_args = []) click to toggle source
# File lib/plugins/puppet-debugger/input_responders/commands.rb, line 11
def run(_args = [])
  commands_list
end