class Debugger::SetCommand

Implements debugger “set” command.

Constants

SubcmdStruct2
Subcommands

Public Class Methods

help(args) click to toggle source
# File lib/ruby-debug/commands/set.rb, line 190
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 = %Q{
    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() click to toggle source
# File lib/ruby-debug/commands/set.rb, line 186
def help_command
  "set"
end

Public Instance Methods

execute() click to toggle source
# 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(%r[ \t]+/)
    subcmd = args.shift
    subcmd.downcase!
    if subcmd =~ %r^no/
      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 %r^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 %r^args$/
            Command.settings[:argv][1..-1] = args
          when %r^autolist$/
            Command.settings[:autolist] = (set_on ? 1 : 0)
          when %r^autoeval$/
            Command.settings[:autoeval] = set_on
          when %r^basename$/
            Command.settings[:basename] = set_on
          when %r^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 %r^trace$/
            Command.settings[:stack_trace_on_error] = set_on
          when %r^fullpath$/
            Command.settings[:full_path] = set_on
          when %r^autoreload$/
            Command.settings[:reload_source_on_change] = set_on
          when %r^autoirb$/
            Command.settings[:autoirb] = (set_on ? 1 : 0)
          when %r^debuggertesting$/
            Command.settings[:debuggertesting] = set_on
            if set_on
              Command.settings[:basename] = true
            end
          when %r^forcestep$/
            self.class.settings[:force_stepping] = set_on
          when %r^history$/
            if 2 == args.size
              interface = @state.interface
              case args[0]
              when %r^save$/
                interface.history_save = get_onoff(args[1])
              when %r^size$/
                interface.history_length = get_int(args[1],
                                                   "Set history size")
              else
                print "Invalid history parameter #{args[0]}. Should be 'save' or 'size'.\n" 
              end
            else
              print "Need two parameters for 'set history'; got #{args.size}.\n" 
              return
            end
          when %r^linetrace\+$/
            self.class.settings[:tracing_plus] = set_on
          when %r^linetrace$/
            Debugger.tracing = set_on
          when %r^listsize$/
            listsize = get_int(args[0], "Set listsize", 1, nil, 10)
            if listsize
              self.class.settings[:listsize] = listsize
            else
              return
            end
          when %r^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() click to toggle source
# File lib/ruby-debug/commands/set.rb, line 55
def regexp
  %r^set (?: \s+ (.*) )?$/x
end