class Byebug::SetCommand
Implements byebug “set” command.
def description
def description %{ Modifies parts of byebug environment. Boolean values take on, off, 1 or 0. You can see these environment settings with the "show" command } end
def execute
def execute return print SetCommand.help(nil) if SetCommand.names.include?(@match[0]) args = @match[1].split(/[ \t]+/) try_subcmd = args.shift try_subcmd.downcase! if try_subcmd =~ /^no/i set_on = false try_subcmd = try_subcmd[2..-1] else set_on = true end subcmd = find(Subcommands, try_subcmd) # Subcommand not found... return print "Unknown set command \"#{try_subcmd}\"\n" unless subcmd set_on = get_onoff(args[0]) if subcmd.is_bool and args.size > 0 case subcmd.name when /^annotate$/ level = get_int(args[0], "Set annotate", 0, 3, 0) if level Byebug.annotate = level else return end when /^args$/ if defined?(Byebug::BYEBUG_SCRIPT) Command.settings[:argv][1..-1] = args else Command.settings[:argv] = args end 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, :tracked Command.settings[:callstyle] = arg else print "Invalid call style #{arg}. Should be one of: " \ "\"short\", \"last\" or \"tracked\".\n" end end 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 /^testing$/ Command.settings[:testing] = set_on Command.settings[:basename] = true if set_on 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$/ Command.settings[:tracing] = set_on when /^listsize$/ listsize = get_int(args[0], "Set listsize", 1, nil, 10) return unless listsize self.class.settings[:listsize] = listsize when /^width$/ width = get_int(args[0], "Set width", 10, nil, 80) return unless width Command.settings[:width] = width ENV['COLUMNS'] = width.to_s else return print "Unknown setting #{@match[1]}.\n" end return print "#{show_setting(subcmd.name)}\n" end
def help(args)
def help(args) if args && args[1] subcmd = SetCommand.new(nil).find(Subcommands, args[1]) if subcmd return "#{subcmd.short_help}.\n#{subcmd.long_help ? subcmd.long_help : ''}" else return "Invalid \"set\" subcommand \"#{args[1]}\".\n" end end description + SetCommand.new(nil).format_subcmds(Subcommands) end
def names
def names %w(set) end
def regexp
def regexp /^set (?: \s+ (.*) )?$/ix end