Sha256: bdb16369d6990a18283ce9481eea2ac41253194232b36e64aae6f1e32f4d26fc

Contents?: true

Size: 1.71 KB

Versions: 17

Compression:

Stored size: 1.71 KB

Contents

module Debugger

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

    # An input line is matched against this regular expression. If we have
    # a match, run this command.
    def regexp
      /^\s* h(?:elp)? (?:\s+(.+))? $/x
    end

    # The code that implements this command.
    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
      # The command name listed via 'help'
      def help_command
        'help'
      end

      # Returns a String given the help description of this command
      def help(cmd)
        %{
          h[elp]\t\tprint this help
          h[elp] command\tprint help on command
        }
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
ruby-debug-0.10.5.rc9 cli/ruby-debug/commands/help.rb
ruby-debug-0.10.5.rc8 cli/ruby-debug/commands/help.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/help.rb
ruby-debug-0.10.5.rc7 cli/ruby-debug/commands/help.rb
ruby-debug-0.10.5.rc5 cli/ruby-debug/commands/help.rb
ruby-debug-0.10.5.rc4 cli/ruby-debug/commands/help.rb
ruby-debug-0.10.5.rc3 cli/ruby-debug/commands/help.rb
ruby-debug-0.10.5.rc2 cli/ruby-debug/commands/help.rb
ruby-debug-0.10.5.rc1 cli/ruby-debug/commands/help.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/help.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/help.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/help.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/help.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/help.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/help.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/help.rb
ruby-debug-0.10.4 cli/ruby-debug/commands/help.rb