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
54
55
56
57
58
59
60
61
62
63
64
65
# 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 /^history$/
    try_subcmd = setting_args[0]
    subcmd = Command.find(SetCommand::SetHistorySubcommands, try_subcmd)
    return print "Invalid history parameter #{try_subcmd}. Should be" \
                 ' "filename", "save" or "size"' unless subcmd

    sub_sub_cmd = setting_args[1]
    iface = @state.interface
    case subcmd.name
    when /^save$/
      iface.history_save = sub_sub_cmd ? get_onoff(sub_sub_cmd) : true
    when /^size$/
      return print 'You need to specify the history size' unless sub_sub_cmd
      iface.history_length = get_int(sub_sub_cmd, "Set history size")
    when /^filename$/
      return print 'You need to specify a filename' unless sub_sub_cmd
      iface.histfile = File.join(ENV["HOME"]||ENV["HOMEPATH"]||".", sub_sub_cmd)
    end
  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
      return print 'Sorry... not implemented yet. Restart byebug'
    end
  when /^autoeval|autoreload|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