Class: Byebug::Command
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Defined in:
- lib/byebug/command.rb
Direct Known Subclasses
AddDisplayCommand, BreakCommand, CatchCommand, ConditionCommand, ContinueCommand, DeleteCommand, DeleteDisplayCommand, DisableCommand, DisplayCommand, DownCommand, EditCommand, EnableCommand, 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, UpCommand, 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.
82
83
84
|
# File 'lib/byebug/command.rb', line 82
def initialize(state)
@match, @state = nil, state
end
|
Class Attribute Details
.allow_in_control ⇒ Object
Returns the value of attribute allow_in_control.
10
11
12
|
# File 'lib/byebug/command.rb', line 10
def allow_in_control
@allow_in_control
end
|
.allow_in_post_mortem ⇒ Object
13
14
15
|
# File 'lib/byebug/command.rb', line 13
def allow_in_post_mortem
@allow_in_post_mortem ||= !defined?(@allow_in_post_mortem) ? true : false
end
|
.always_run ⇒ Object
17
18
19
|
# File 'lib/byebug/command.rb', line 17
def always_run
@always_run ||= 0
end
|
.unknown ⇒ Object
Returns the value of attribute unknown.
10
11
12
|
# File 'lib/byebug/command.rb', line 10
def unknown
@unknown
end
|
Class Method Details
.commands ⇒ Object
63
64
65
|
# File 'lib/byebug/command.rb', line 63
def commands
@commands ||= []
end
|
.find(subcmds, param) ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/byebug/command.rb', line 31
def find(subcmds, param)
param.downcase!
for try_subcmd in subcmds do
if (param.size >= try_subcmd.min) and
(try_subcmd.name[0..param.size-1] == param)
return try_subcmd
end
end
return nil
end
|
42
43
44
45
46
47
48
|
# File 'lib/byebug/command.rb', line 42
def format_subcmd(subcmd_name)
subcmd = find(self::Subcommands, subcmd_name)
return "Invalid \"#{names.join("|")}\" " \
"subcommand \"#{args[1]}\"." unless subcmd
return "#{subcmd.help}.\n"
end
|
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/byebug/command.rb', line 50
def format_subcmds
cmd_name = names.join("|")
s = "\n" \
"--\n" \
"List of \"#{cmd_name}\" subcommands:\n" \
"--\n"
w = self::Subcommands.map(&:name).max_by(&:size).size
for subcmd in self::Subcommands do
s += sprintf "%s %-#{w}s -- %s\n", cmd_name, subcmd.name, subcmd.help
end
return s
end
|
.help(args) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/byebug/command.rb', line 21
def help(args)
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
67
68
69
|
# File 'lib/byebug/command.rb', line 67
def inherited(klass)
commands << klass
end
|
.load_commands ⇒ Object
71
72
73
74
75
76
77
78
79
|
# File 'lib/byebug/command.rb', line 71
def load_commands
Dir.glob(File.expand_path('../commands/*.rb', __FILE__)).each do |file|
require file
end
Byebug.constants.grep(/Functions$/).map {
|name| Byebug.const_get(name)
}.each { |mod| include mod }
end
|
Instance Method Details
#match(input) ⇒ Object
86
87
88
|
# File 'lib/byebug/command.rb', line 86
def match(input)
@match = regexp.match(input)
end
|