Sha256: da5c57d20085d7121a3dd7277874a6ffc1397d77821a50c367b1fe9a70647882

Contents?: true

Size: 1.45 KB

Versions: 43

Compression:

Stored size: 1.45 KB

Contents

module Debugger

  # Implements debugger "help" command.
  class HelpCommand < Command
    self.allow_in_control = true

    def regexp
      /^\s* h(?:elp)? (?:\s+(.+))? $/x
    end

    def execute
      if @match[1]
        args = @match[1].split
        cmds = @state.commands.select do |cmd| 
          [cmd.help_command].flatten.include?(args[0])
        end
      else
        args = @match[1]
        cmds = []
      end
      unless cmds.empty?
        help = cmds.map{ |cmd| cmd.help(args) }.join
        help = help.split("\n").map{|l| l.gsub(/^ +/, '')}
        help.shift if help.first && help.first.empty?
        help.pop if help.last && help.last.empty?
        print help.join("\n")
      else
        if args and args[0]
          errmsg "Undefined command: \"#{args[0]}\".  Try \"help\"."
        else
          print "ruby-debug help v#{Debugger::VERSION}\n" unless
            self.class.settings[:debuggertesting]
          print "Type 'help <command-name>' for help on a specific command\n\n"
          print "Available commands:\n"
          cmds = @state.commands.map{ |cmd| cmd.help_command }
          cmds = cmds.flatten.uniq.sort
          print columnize(cmds, self.class.settings[:width])
        end
      end
      print "\n"
    end

    class << self
      def help_command
        'help'
      end

      def help(cmd)
        %{
          h[elp]\t\tprint this help
          h[elp] command\tprint help on command
        }
      end
    end
  end
end

Version data entries

43 entries across 42 versions & 10 rubygems

Version Path
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/debugger-1.6.8/lib/ruby-debug/commands/help.rb
debugger-1.6.8 lib/ruby-debug/commands/help.rb
debugger-1.6.7 lib/ruby-debug/commands/help.rb
debugger-1.6.6 lib/ruby-debug/commands/help.rb
debugger-1.6.5 lib/ruby-debug/commands/help.rb
debugger-1.6.4 lib/ruby-debug/commands/help.rb
debugger-1.6.3 lib/ruby-debug/commands/help.rb
debugger-1.6.2 lib/ruby-debug/commands/help.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/debugger-1.6.1/lib/ruby-debug/commands/help.rb
candlepin-api-0.4.0 bundle/ruby/gems/debugger-1.6.1/lib/ruby-debug/commands/help.rb
debugger-1.6.1 lib/ruby-debug/commands/help.rb
debugger-1.6.0 lib/ruby-debug/commands/help.rb
debugger2-1.0.0.beta2 lib/ruby-debug/commands/help.rb
debugger2-1.0.0.beta1 lib/ruby-debug/commands/help.rb
debugger-1.5.0 lib/ruby-debug/commands/help.rb
needy_debugger-1.4.0 lib/ruby-debug/commands/help.rb
debugger-1.4.0 lib/ruby-debug/commands/help.rb
debugger-1.3.3 lib/ruby-debug/commands/help.rb
debugger-1.3.2 lib/ruby-debug/commands/help.rb
debugger-1.3.1 lib/ruby-debug/commands/help.rb