Class: Byebug::Command
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Defined in:
- lib/byebug/command.rb
Overview
Parent class of all byebug commands.
Subclasses need to implement a ‘regexp` and an `execute` command.
Direct Known Subclasses
AddDisplayCommand, BreakCommand, CatchCommand, ConditionCommand, ContinueCommand, DeleteCommand, DisplayCommand, DownCommand, EditCommand, EnableDisableCommand, EvalCommand, FinishCommand, FrameCommand, HelpCommand, HistoryCommand, InfoCommand, InterruptCommand, IrbCommand, KillCommand, ListCommand, MethodCommand, NextCommand, PPCommand, PSCommand, PryCommand, PutLCommand, QuitCommand, ReloadCommand, RestartCommand, SaveCommand, SetCommand, ShowCommand, SourceCommand, StepCommand, ThreadCurrentCommand, ThreadListCommand, ThreadResumeCommand, ThreadStopCommand, ThreadSwitchCommand, TraceCommand, UndisplayCommand, UpCommand, VarAllCommand, VarClassCommand, VarConstantCommand, VarGlobalCommand, VarInstanceCommand, VarLocalCommand, WhereCommand
Defined Under Namespace
Classes: Subcmd
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(state) ⇒ Command
Returns a new instance of Command.
14
15
16
|
# File 'lib/byebug/command.rb', line 14
def initialize(state)
@match, @state = nil, state
end
|
Class Attribute Details
.allow_in_control ⇒ Object
Returns the value of attribute allow_in_control.
52
53
54
|
# File 'lib/byebug/command.rb', line 52
def allow_in_control
@allow_in_control
end
|
.allow_in_post_mortem ⇒ Object
55
56
57
|
# File 'lib/byebug/command.rb', line 55
def allow_in_post_mortem
!defined?(@allow_in_post_mortem) ? true : false
end
|
.always_run ⇒ Object
59
60
61
|
# File 'lib/byebug/command.rb', line 59
def always_run
@always_run ||= 0
end
|
Class Method Details
.commands ⇒ Object
102
103
104
|
# File 'lib/byebug/command.rb', line 102
def commands
@commands ||= []
end
|
.find(subcmds, str) ⇒ Object
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/byebug/command.rb', line 73
def find(subcmds, str)
str.downcase!
subcmds.each do |subcmd|
if (str.size >= subcmd.min) && (subcmd.name[0..str.size - 1] == str)
return subcmd
end
end
nil
end
|
84
85
86
87
88
89
90
|
# File 'lib/byebug/command.rb', line 84
def format_subcmd(subcmd_name)
subcmd = find(self::Subcommands, subcmd_name)
return "Invalid \"#{names.join('|')}\" " \
"subcommand \"#{args[1]}\"." unless subcmd
"\n #{subcmd.help}.\n\n"
end
|
92
93
94
95
96
97
98
99
100
|
# File 'lib/byebug/command.rb', line 92
def format_subcmds
= names.join('|')
s = " List of \"#{}\" subcommands:\n --\n"
w = self::Subcommands.map(&:name).max_by(&:size).size
self::Subcommands.each do |subcmd|
s += format(" %s %-#{w}s -- %s\n", , subcmd.name, subcmd.help)
end
s + "\n"
end
|
.help(args = nil) ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'lib/byebug/command.rb', line 63
def help(args = nil)
if args && args[1]
output = format_subcmd(args[1])
else
output = description.gsub(/^ +/, '') + "\n"
output += format_subcmds if defined? self::Subcommands
end
output
end
|
.inherited(klass) ⇒ Object
106
107
108
|
# File 'lib/byebug/command.rb', line 106
def inherited(klass)
commands << klass
end
|
.load_commands ⇒ Object
110
111
112
113
114
115
116
117
118
|
# File 'lib/byebug/command.rb', line 110
def load_commands
Dir.glob(File.expand_path('../commands/*.rb', __FILE__)).each do |file|
require file
end
Byebug.constants.grep(/Functions$/).map do |name|
include Byebug.const_get(name)
end
end
|
Instance Method Details
#match(input) ⇒ Object
18
19
20
|
# File 'lib/byebug/command.rb', line 18
def match(input)
@match = regexp.match(input)
end
|