Class: Byebug::Command
- Inherits:
-
Object
- Object
- Byebug::Command
- Extended by:
- Helpers::StringHelper, Forwardable
- Defined in:
- lib/byebug/command.rb
Overview
Parent class of all byebug commands.
Subclass it and name the subclass ending with the word Command to implement your own custom command.
class MyCustomCommand < Command
def self.regexp
/custom_regexp/
end
def self.description
"Custom long desc"
end
def.short_description
"Custom short desc"
end
def execute
# My command's implementation
end
end
Direct Known Subclasses
BreakCommand, CatchCommand, ConditionCommand, ContinueCommand, DebugCommand, DeleteCommand, DisableCommand, DisableCommand::BreakpointsCommand, DisableCommand::DisplayCommand, DisplayCommand, DownCommand, EditCommand, EnableCommand, EnableCommand::BreakpointsCommand, EnableCommand::DisplayCommand, FinishCommand, FrameCommand, HelpCommand, HistoryCommand, InfoCommand, InfoCommand::BreakpointsCommand, InfoCommand::DisplayCommand, InfoCommand::FileCommand, InfoCommand::LineCommand, InfoCommand::ProgramCommand, InterruptCommand, IrbCommand, KillCommand, ListCommand, MethodCommand, NextCommand, PryCommand, QuitCommand, RestartCommand, SaveCommand, SetCommand, ShowCommand, SkipCommand, SourceCommand, StepCommand, ThreadCommand, ThreadCommand::CurrentCommand, ThreadCommand::ListCommand, ThreadCommand::ResumeCommand, ThreadCommand::StopCommand, ThreadCommand::SwitchCommand, TracevarCommand, UndisplayCommand, UntracevarCommand, UpCommand, VarCommand, VarCommand::AllCommand, VarCommand::ArgsCommand, VarCommand::ConstCommand, VarCommand::GlobalCommand, VarCommand::InstanceCommand, VarCommand::LocalCommand, WhereCommand
Class Attribute Summary collapse
-
.allow_in_control ⇒ Object
Special methods to allow command filtering in processors.
-
.allow_in_post_mortem ⇒ Object
Special methods to allow command filtering in processors.
- .always_run ⇒ Object
Instance Attribute Summary collapse
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
Class Method Summary collapse
- .columnize(width) ⇒ Object
-
.help ⇒ Object
Default help text for a command.
-
.match(input) ⇒ Object
Command’s regexp match against an input.
-
.to_s ⇒ Object
Name of the command, as executed by the user.
Instance Method Summary collapse
- #arguments ⇒ Object
- #context ⇒ Object
- #frame ⇒ Object
-
#initialize(processor, input = self.class.to_s) ⇒ Command
constructor
A new instance of Command.
Methods included from Helpers::StringHelper
Constructor Details
#initialize(processor, input = self.class.to_s) ⇒ Command
Returns a new instance of Command.
38 39 40 41 |
# File 'lib/byebug/command.rb', line 38 def initialize(processor, input = self.class.to_s) @processor = processor @match = match(input) end |
Class Attribute Details
.allow_in_control ⇒ Object
Special methods to allow command filtering in processors
69 70 71 |
# File 'lib/byebug/command.rb', line 69 def allow_in_control @allow_in_control end |
.allow_in_post_mortem ⇒ Object
Special methods to allow command filtering in processors
69 70 71 |
# File 'lib/byebug/command.rb', line 69 def allow_in_post_mortem @allow_in_post_mortem end |
.always_run ⇒ Object
73 74 75 |
# File 'lib/byebug/command.rb', line 73 def always_run @always_run ||= 0 end |
Instance Attribute Details
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
36 37 38 |
# File 'lib/byebug/command.rb', line 36 def processor @processor end |
Class Method Details
.columnize(width) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/byebug/command.rb', line 88 def columnize(width) format( " %-<name>#{width}s -- %<description>s\n", name: to_s, description: short_description ) end |
.help ⇒ Object
Default help text for a command.
99 100 101 |
# File 'lib/byebug/command.rb', line 99 def help prettify(description) end |
.match(input) ⇒ Object
Command’s regexp match against an input
106 107 108 |
# File 'lib/byebug/command.rb', line 106 def match(input) regexp.match(input) end |
.to_s ⇒ Object
Name of the command, as executed by the user.
80 81 82 83 84 85 86 |
# File 'lib/byebug/command.rb', line 80 def to_s name .split("::") .map { |n| n.gsub(/Command$/, "").downcase if /Command$/.match?(n) } .compact .join(" ") end |
Instance Method Details
#arguments ⇒ Object
51 52 53 |
# File 'lib/byebug/command.rb', line 51 def arguments @match[0].split(" ").drop(1).join(" ") end |
#context ⇒ Object
43 44 45 |
# File 'lib/byebug/command.rb', line 43 def context @context ||= processor.context end |
#frame ⇒ Object
47 48 49 |
# File 'lib/byebug/command.rb', line 47 def frame @frame ||= context.frame end |