Class: Debugger::SetCommand
- Defined in:
- lib/ruby-debug/commands/set.rb
Overview
Implements debugger “set” command.
Defined Under Namespace
Classes: SubcmdStruct2
Constant Summary collapse
- Subcommands =
[ ['annotate', 2, false, "Set annotation level", "0 == normal; 2 == output annotated suitably for use by programs that control ruby-debug."], ['args', 2, false, "Set argument list to give program being debugged when it is started", "Follow this command with any number of args, to be passed to the program."], ['autoeval', 4, true, "Evaluate every unrecognized command"], ['autolist', 4, true, "Execute 'list' command on every breakpoint"], ['autoirb', 4, true, "Invoke IRB on every stop"], ['autoreload', 4, true, "Reload source code when changed"], ['basename', 1, true, "Report file basename only showing file names"], ['callstyle', 2, false, "Set how you want call parameters displayed"], ['debuggertesting', 8, false, "Used when testing the debugger"], ['forcestep', 2, true, "Make sure 'next/step' commands always move to a new line"], ['fullpath', 2, true, "Display full file names in frames"], ['history', 2, false, "Generic command for setting command history parameters", "set history filename -- Set the filename in which to record the command history set history save -- Set saving of the history record on exit set history size -- Set the size of the command history"], ['linetrace+', 10, true, "Set line execution tracing to show different lines"], ['linetrace', 3, true, "Set line execution tracing"], ['listsize', 3, false, "Set number of source lines to list by default"], ['trace', 1, true, "Display stack trace when 'eval' raises exception"], ['width', 1, false, "Number of characters the debugger thinks are in a line"], ].map do |name, min, is_bool, short_help, long_help| SubcmdStruct2.new(name, min, is_bool, short_help, long_help) end
Constants inherited from Command
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Command
commands, #find, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map
Constructor Details
This class inherits a constructor from Debugger::Command
Class Method Details
.help(args) ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/ruby-debug/commands/set.rb', line 192 def help(args) if args[1] s = args[1] subcmd = Subcommands.find do |try_subcmd| (s.size >= try_subcmd.min) and (try_subcmd.name[0..s.size-1] == s) end if subcmd str = subcmd.short_help + '.' str += "\n" + subcmd.long_help if subcmd.long_help return str else return "Invalid 'set' subcommand '#{args[1]}'." end end s = %{ Modifies parts of the ruby-debug environment. Boolean values take on, off, 1 or 0. You can see these environment settings with the \"show\" command. -- List of set subcommands: -- } for subcmd in Subcommands do s += "set #{subcmd.name} -- #{subcmd.short_help}\n" end return s end |
.help_command ⇒ Object
188 189 190 |
# File 'lib/ruby-debug/commands/set.rb', line 188 def help_command "set" end |
Instance Method Details
#execute ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/ruby-debug/commands/set.rb', line 59 def execute if not @match[1] print "\"set\" must be followed by the name of an set command:\n" print "List of set subcommands:\n\n" for subcmd in Subcommands do print "set #{subcmd.name} -- #{subcmd.short_help}\n" end else args = @match[1].split(/[ \t]+/) subcmd = args.shift subcmd.downcase! if subcmd =~ /^no/i set_on = false subcmd = subcmd[2..-1] else set_on = true end for try_subcmd in Subcommands do if (subcmd.size >= try_subcmd.min) and (try_subcmd.name[0..subcmd.size-1] == subcmd) begin if try_subcmd.is_bool if args.size > 0 set_on = get_onoff(args[0]) end end case try_subcmd.name when /^annotate$/ level = get_int(args[0], "Set annotate", 0, 3, 0) if level Debugger.annotate = level else return end if defined?(Debugger::RDEBUG_SCRIPT) # rdebug was called initially. 1st arg is script name. Command.settings[:argv][1..-1] = args else # rdebug wasn't called initially. 1st arg is not script name. Command.settings[:argv] = args end when /^args$/ Command.settings[:argv][1..-1] = args when /^autolist$/ Command.settings[:autolist] = (set_on ? 1 : 0) when /^autoeval$/ Command.settings[:autoeval] = set_on when /^basename$/ Command.settings[:basename] = set_on when /^callstyle$/ if args[0] arg = args[0].downcase.to_sym case arg when :short, :last Command.settings[:callstyle] = arg print "%s\n" % show_setting(try_subcmd.name) return end end print "Invalid call style #{arg}. Should be one of: " + "'short' or 'last'.\n" when /^trace$/ Command.settings[:stack_trace_on_error] = set_on when /^fullpath$/ Command.settings[:full_path] = set_on when /^autoreload$/ Command.settings[:reload_source_on_change] = set_on when /^autoirb$/ Command.settings[:autoirb] = (set_on ? 1 : 0) when /^debuggertesting$/ Command.settings[:debuggertesting] = set_on if set_on Command.settings[:basename] = true end when /^forcestep$/ self.class.settings[:force_stepping] = set_on when /^history$/ if 2 == args.size interface = @state.interface case args[0] when /^save$/ interface.history_save = get_onoff(args[1]) when /^size$/ interface.history_length = get_int(args[1], "Set history size") when /^filename$/ interface.histfile = File.join(ENV["HOME"]||ENV["HOMEPATH"]||".", args[1]) else print "Invalid history parameter #{args[0]}. Should be 'filename', 'save' or 'size'.\n" end else print "Need two parameters for 'set history'; got #{args.size}.\n" return end when /^linetrace\+$/ self.class.settings[:tracing_plus] = set_on when /^linetrace$/ Debugger.tracing = set_on when /^listsize$/ listsize = get_int(args[0], "Set listsize", 1, nil, 10) if listsize self.class.settings[:listsize] = listsize else return end when /^width$/ width = get_int(args[0], "Set width", 10, nil, 80) if width self.class.settings[:width] = width ENV['COLUMNS'] = width.to_s else return end else print "Unknown setting #{@match[1]}.\n" return end print "%s\n" % show_setting(try_subcmd.name) return rescue RuntimeError return end end end print "Unknown set command #{subcmd}\n" end end |
#regexp ⇒ Object
55 56 57 |
# File 'lib/ruby-debug/commands/set.rb', line 55 def regexp /^set (?: \s+ (.*) )?$/ix end |