Class: Byebug::Command
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, RestartCommand, SaveCommand, SetCommand, ShowCommand, SourceCommand, StepCommand, ThreadCommand, TracevarCommand, UndisplayCommand, UntracevarCommand, UpCommand, VarCommand, WhereCommand
Defined Under Namespace
Classes: Subcmd
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
camelize, prettify
#get_line, #get_lines, #n_lines, #normalize
#get_int, #parse_steps, #syntax_valid?, #without_stderr
Constructor Details
#initialize(state) ⇒ Command
Returns a new instance of Command.
19
20
21
|
# File 'lib/byebug/command.rb', line 19
def initialize(state)
@match, @state = nil, state
end
|
Class Attribute Details
.allow_in_control ⇒ Object
Returns the value of attribute allow_in_control.
70
71
72
|
# File 'lib/byebug/command.rb', line 70
def allow_in_control
@allow_in_control
end
|
.allow_in_post_mortem ⇒ Object
73
74
75
|
# File 'lib/byebug/command.rb', line 73
def allow_in_post_mortem
!defined?(@allow_in_post_mortem) ? true : false
end
|
.always_run ⇒ Object
77
78
79
|
# File 'lib/byebug/command.rb', line 77
def always_run
@always_run ||= 0
end
|
Class Method Details
.commands ⇒ Object
118
119
120
|
# File 'lib/byebug/command.rb', line 118
def commands
@commands ||= []
end
|
.find(subcmds, str) ⇒ Object
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/byebug/command.rb', line 89
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
|
100
101
102
103
104
105
106
|
# File 'lib/byebug/command.rb', line 100
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
|
108
109
110
111
112
113
114
115
116
|
# File 'lib/byebug/command.rb', line 108
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(subcmd = nil) ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/byebug/command.rb', line 81
def help(subcmd = nil)
return format_subcmd(subcmd) if subcmd
output = description
output += format_subcmds if defined? self::Subcommands
output
end
|
.inherited(klass) ⇒ Object
122
123
124
|
# File 'lib/byebug/command.rb', line 122
def inherited(klass)
commands << klass
end
|
Instance Method Details
#match(input) ⇒ Object
23
24
25
|
# File 'lib/byebug/command.rb', line 23
def match(input)
@match = regexp.match(input)
end
|