Class: Byebug::RestartCommand
Constant Summary
Constants inherited
from Command
Command::DEF_OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map
Class Method Details
.description ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/byebug/commands/control.rb', line 62
def description
%{
restart|R [args]
Restart the program. This is a re-exec - all byebug state
is lost. If command arguments are passed those are used.
}
end
|
.names ⇒ Object
58
59
60
|
# File 'lib/byebug/commands/control.rb', line 58
def names
%w(restart)
end
|
Instance Method Details
#execute ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/byebug/commands/control.rb', line 14
def execute
return errmsg "Don't know name of debugged program\n" unless
defined? Byebug::PROG_SCRIPT
return errmsg "Ruby program #{Byebug::PROG_SCRIPT} doesn't exist\n" unless
File.exist?(File.expand_path(Byebug::PROG_SCRIPT))
if not defined? Byebug::BYEBUG_SCRIPT
print "Byebug was not called from the outset...\n"
if not File.executable?(Byebug::PROG_SCRIPT)
print "Ruby program #{Byebug::PROG_SCRIPT} not executable... " \
"We'll add a call to Ruby.\n"
ruby = begin defined?(Gem) ? Gem.ruby : "ruby" rescue "ruby" end
cmd = "#{ruby} -I#{$:.join(' -I')} #{Byebug::PROG_SCRIPT}"
else
cmd = Byebug::PROG_SCRIPT
end
else
cmd = "#{Byebug::BYEBUG_SCRIPT} #{Byebug::PROG_SCRIPT}"
end
begin
Dir.chdir(Byebug::INITIAL_DIR)
rescue
print "Failed to change initial directory #{Byebug::INITIAL_DIR}"
end
if @match[1]
cmd += " #{@match[1]}"
elsif not defined? Command.settings[:argv]
return errmsg "Arguments not set. Use 'set args' to set them.\n"
else
require 'shellwords'
cmd += " #{Command.settings[:argv].compact.shelljoin}"
end
print "Re exec'ing:\n\t#{cmd}\n"
exec cmd
rescue Errno::EOPNOTSUPP
print "Restart command is not available at this time.\n"
end
|
#regexp ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/byebug/commands/control.rb', line 6
def regexp
/ ^\s*
(?:restart|R)
(?:\s+ (\S?.*\S))? \s*
$
/ix
end
|