Class: Byebug::SetCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/byebug/commands/set.rb

Overview

Implements byebug “set” command.

Defined Under Namespace

Classes: Subcmd2

Constant Summary collapse

Subcommands =
[
  ['args'          , 2 , false, 'Set argument list to the program '    \
                                'being debugged when it is started'       ],
  ['autoeval'      , 4 , true , 'Evaluate every unrecognized command'     ],
  ['autolist'      , 4 , true , 'Execute "list" command on every '     \
                                'breakpoint'                              ],
  ['autoirb'       , 4 , true , 'Invoke IRB on every stop'                ],
  ['autoreload'    , 4 , true , 'Reload source code when changed'         ],
  ['basename'      , 1 , true , 'Set filename display style'              ],
  ['callstyle'     , 2 , false, 'Set how you want call parameters '    \
                                'displayed'                               ],
  ['testing'       , 2 , false, 'Used when testing byebug'                ],
  ['forcestep'     , 2 , true , 'Make sure "next/step" commands always' \
                                'move to a new line'                      ],
  ['fullpath'      , 2 , true , 'Display full file names in frames'       ],
  ['history'       , 2 , false, 'Command for setting command history '  \
                                'parameters, namely, "filename", '      \
                                '"save" and "size"'                       ],
  ['linetrace'     , 3 , true , 'Enable line execution tracing'           ],
  ['linetrace_plus', 10, true , 'Set line execution tracing to show'    \
                                'different lines'                         ],
  ['listsize'      , 3 , false, 'Set number of source lines to list by' \
                                'default'                                 ],
  ['post_mortem'   , 2 , true , 'Enable post-mortem mode'                 ],
  ['stack_on_error', 1 , true , 'Display stack trace when "eval" '      \
                                'raises exception'                        ],
  ['verbose'       , 1 , true , 'Enable verbose output of TracePoint '  \
                                'API events is enabled'                   ],
  ['width'         , 1 , false, 'Number of characters per line for '    \
                                'byebug\'s output'                        ]
].map do |name, min, is_bool, help|
  Subcmd2.new(name, min, is_bool, help)
end
SetHistorySubcommands =
[
  ['filename', 1, 'Set the filename in which to record command history'],
  ['save'    , 1, 'Set saving of the history record on exit'           ],
  ['size'    , 1, 'Set the size of the command history'                ]
].map do |name, min, help|
  Subcmd.new(name, min, help)
end

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

command_exists?, commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match, register_setting_get, register_setting_set, register_setting_var, settings, settings_map, terminal_width

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



152
153
154
155
# File 'lib/byebug/commands/set.rb', line 152

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

.namesObject



148
149
150
# File 'lib/byebug/commands/set.rb', line 148

def names
  %w(set)
end

Instance Method Details

#executeObject



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/byebug/commands/set.rb', line 120

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 = Command.find(Subcommands, try_subcmd)
  return print "Unknown set command \"#{try_subcmd}\"\n" unless subcmd

  begin
    set_on = get_onoff(args[0]) if subcmd.is_bool and args.size > 0
  rescue RuntimeError
    return
  end

  set_setting(subcmd.name, set_on, args)

  return print "#{show_setting(subcmd.name)}\n"
end

#regexpObject



116
117
118
# File 'lib/byebug/commands/set.rb', line 116

def regexp
  /^\s* set (?:\s+(.*))? \s*$/x
end