lib/byebug/commands/set.rb in byebug-3.5.1 vs lib/byebug/commands/set.rb in byebug-4.0.0

- old
+ new

@@ -1,5 +1,7 @@ +require 'byebug/command' + module Byebug # # Change byebug settings. # class SetCommand < Command @@ -11,25 +13,25 @@ def execute key, value = @match[:setting], @match[:value] return puts(SetCommand.help) if key.nil? && value.nil? - full_key = Setting.find(key) - return errmsg("Unknown setting :#{key}") unless full_key + setting = Setting.find(key) + return errmsg(pr('set.errors.unknown_setting', key: key)) unless setting - if !Setting.boolean?(full_key) && value.nil? - value, err = nil, "You must specify a value for setting :#{key}" - elsif Setting.boolean?(full_key) + if !setting.boolean? && value.nil? + value, err = nil, pr('set.errors.must_specify_value', key: key) + elsif setting.boolean? value, err = get_onoff(value, key =~ /^no/ ? false : true) - elsif Setting.integer?(full_key) - value, err = get_int(value, full_key, 1) + elsif setting.integer? + value, err = get_int(value, setting.to_sym, 1) end return errmsg(err) if value.nil? - Setting[full_key.to_sym] = value + setting.value = value - puts Setting.settings[full_key.to_sym].to_s + puts setting.to_s end def get_onoff(arg, default) return default if arg.nil? @@ -37,22 +39,21 @@ when '1', 'on', 'true' true when '0', 'off', 'false' false else - [nil, "Expecting 'on', 1, true, 'off', 0, false. Got: #{arg}.\n"] + [nil, pr('set.errors.on_off', arg: arg)] end end class << self def names %w(set) end def description - <<-EOD.gsub(/^ /, '') - + prettify <<-EOD set <setting> <value> Modifies parts of byebug environment. Boolean values take "on", "off", "true", "false", "1" or "0". If you @@ -61,11 +62,11 @@ You can see these environment settings with the "show" command. EOD end - def help(subcmds = []) - Setting.help('set', subcmds.first) + def help(subcmd = nil) + Setting.help('set', subcmd) end end end end