Module: Byebug::SetFunctions

Defined in:
lib/byebug/commands/set.rb

Overview

Mix-in module to setting settings

Instance Method Summary collapse

Instance Method Details

#set_setting(setting_name, setting_value, setting_args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/byebug/commands/set.rb', line 6

def set_setting(setting_name, setting_value, setting_args)
  case setting_name
  when /^args$/
    if defined?(Byebug::BYEBUG_SCRIPT)
      Command.settings[:argv][1..-1] = setting_args
    else
      Command.settings[:argv] = setting_args
    end
  when /^autoirb$/
    Command.settings[:autoirb] = (setting_value ? 1 : 0)
  when /^autolist$/
    Command.settings[:autolist] = (setting_value ? 1 : 0)
  when /^callstyle$/
    if setting_args[0] and ['short', 'long'].include?(setting_args[0])
      Command.settings[:callstyle] = setting_args[0].to_sym
    else
      print "Invalid callstyle. Should be one of: \"short\" or \"long\"\n"
    end
  when /^verbose$/
    Byebug.verbose = setting_value
  when /^histfile$/
    return print 'You need to specify a filename' unless setting_args[0]
    Byebug::History.file = File.expand_path(setting_args[0])
  when /^histsize$/
    return print 'You need to specify the history size' unless setting_args[0]
    Byebug::History.max_size = get_int(setting_args[0], "Set histsize")
  when /^linetrace$/
    Byebug.tracing = setting_value
  when /^listsize$/
    listsize = get_int(setting_args[0], 'Set listsize', 1, nil, 10)
    return unless listsize
    Command.settings[:listsize] = listsize
  when /^width$/
    return unless width = get_int(setting_args[0], 'Set width', 10, nil, 80)
    Command.settings[:width] = width
  when /^post_mortem$/
    if setting_value == true
      Byebug.post_mortem
    else
      Byebug.post_mortem = false
    end
  when /^autoeval|autoreload|autosave|basename|forcestep|fullpath|
         linetrace_plus|testing|stack_on_error$/x
    Command.settings[setting_name.to_sym] = setting_value
  else
    return print "Unknown setting #{@match[1]}.\n"
  end
end