Sha256: b984a8ae856f4d17680db50afcea6cf44edb65f6d77bf5141ee7938afbcf059f
Contents?: true
Size: 1.8 KB
Versions: 5
Compression:
Stored size: 1.8 KB
Contents
# -*- coding: utf-8 -*- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net> require_relative '../../base/subsubcmd' class Trepan::SubSubcommand::SetAutoEval < Trepan::SetBoolSubSubcommand unless defined?(HELP) HELP = "Evaluate unrecognized debugger commands. Often inside the debugger, one would like to be able to run arbitrary Ruby commands without having to preface Python expressions with \"print\" or \"eval\". Setting \"auto eval\" on will cause unrecognized debugger commands to be eval'd as a Ruby expression. Note that if this is set, on error the message shown on type a bad debugger command changes from: Undefined command: \"fdafds\". Try \"help\". to something more Ruby-eval-specific such as: NameError: name 'fdafds' is not defined One other thing that trips people up is when setting auto eval is that there are some short debugger commands that sometimes one wants to use as a variable, such as in an assignment statement. For example: s = 5 which produce when 'auto eval' is on: *** Command 'step' can take at most 1 argument(s); got 2. because by default, 's' is an alias for the debugger 'step' command. It is possible to remove that alias if this causes constant problem. Another possibility is to go into a real Ruby shell via the 'irb' command. " MIN_ABBREV = 'ev'.size NAME = File.basename(__FILE__, '.rb') PREFIX = %W(set auto #{NAME}) SHORT_HELP = "Set evaluation of unrecognized debugger commands" end end if __FILE__ == $0 # Demo it. require_relative '../../../mock' require_relative '../auto' cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetAuto, Trepan::SubSubcommand::SetAutoEval) %w(off on 0 1).each { |arg| cmd.run([cmd.name, arg]) } puts '-' * 10 puts cmd.save_command.join("\n") end
Version data entries
5 entries across 5 versions & 1 rubygems