Sha256: 2c518cf9fe202fbea83d1bcef0ab73424f1d249561ade7586370407bda41d29d
Contents?: true
Size: 1.1 KB
Versions: 6
Compression:
Stored size: 1.1 KB
Contents
module Debugger class HelpCommand < Command 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
6 entries across 6 versions & 1 rubygems