Sha256: e01a5e32eb15751d32401ed58d9ce8b109ba040d715740c16caac57d7bb60126
Contents?: true
Size: 1.11 KB
Versions: 33
Compression:
Stored size: 1.11 KB
Contents
module Debugger class HelpCommand < Command # :nodoc: self.control = true def regexp /^\s*h(?:elp)?(?:\s+(.+))?$/ end def execute print "ruby-debug help v.#{Debugger::VERSION}\n" cmds = @state.commands.select{ |cmd| [cmd.help_command].flatten.include?(@match[1]) } unless cmds.empty? help = cmds.map{ |cmd| cmd.help(@match[1]) }.join print help.split("\n").reject{|l| l =~ /^\s*$/ }.map{|l| l.gsub(/^ +/, '')}.join("\n") else print "Available commands:\n" cmds = @state.commands.map{ |cmd| cmd.help_command } cmds = cmds.flatten.uniq.sort buf = "" cmds.each do |cmd| if buf.length + cmd.length > 70 print "%s\n", buf buf = "" else buf << cmd << ' ' end end print "%s\n", buf if buf.length > 0 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
33 entries across 33 versions & 1 rubygems