Class: Byebug::SetCommand
Overview
Instance Attribute Summary
Attributes inherited from Command
#processor
Class Method Summary
collapse
Instance Method Summary
collapse
#get_int, #parse_steps, #syntax_valid?
Methods inherited from Command
#arguments, columnize, #context, #frame, #initialize, match, to_s
#camelize, #prettify
Class Method Details
.description ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/byebug/commands/set.rb', line 18
def self.description
<<-EOD
set <setting> <value>
#{short_description}
Boolean values take "on", "off", "true", "false", "1" or "0". If you
don't specify a value, the boolean setting will be enabled. Conversely,
you can use "set no<setting>" to disable them.
You can see these environment settings with the "show" command.
EOD
end
|
.help ⇒ Object
36
37
38
|
# File 'lib/byebug/commands/set.rb', line 36
def self.help
super + Setting.help_all
end
|
.regexp ⇒ Object
14
15
16
|
# File 'lib/byebug/commands/set.rb', line 14
def self.regexp
/^\s* set (?:\s+(?<setting>\w+))? (?:\s+(?<value>\S+))? \s*$/x
end
|
.short_description ⇒ Object
32
33
34
|
# File 'lib/byebug/commands/set.rb', line 32
def self.short_description
'Modifies byebug settings'
end
|
Instance Method Details
#execute ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/byebug/commands/set.rb', line 40
def execute
key = @match[:setting]
value = @match[:value]
return puts(help) if key.nil? && value.nil?
setting = Setting.find(key)
return errmsg(pr('set.errors.unknown_setting', key: key)) unless setting
if !setting.boolean? && value.nil?
err = pr('set.errors.must_specify_value', key: key)
elsif setting.boolean?
value, err = get_onoff(value, key =~ /^no/ ? false : true)
elsif setting.integer?
value, err = get_int(value, setting.to_sym, 1)
end
return errmsg(err) if value.nil?
setting.value = value
puts setting.to_s
end
|