Class: Byebug::RestartCommand

Inherits:
Command
  • Object
show all
Includes:
Helpers::BinHelper, Helpers::PathHelper
Defined in:
lib/byebug/commands/restart.rb

Overview

Restart debugged program from within byebug.

Instance Attribute Summary

Attributes inherited from Command

#processor

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::PathHelper

#all_files, #bin_file, #gem_files, #lib_files, #root_path, #test_files

Methods included from Helpers::BinHelper

#which

Methods inherited from Command

#arguments, columnize, #context, #frame, help, #initialize, match, to_s

Methods included from Helpers::StringHelper

#camelize, #deindent, #prettify

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/byebug/commands/restart.rb', line 23

def self.description
  <<-EOD
    restart [args]

    #{short_description}

    This is a re-exec - all byebug state is lost. If command arguments are
    passed those are used.
  EOD
end

.regexpObject



19
20
21
# File 'lib/byebug/commands/restart.rb', line 19

def self.regexp
  /^\s* restart (?:\s+(?<args>.+))? \s*$/x
end

.short_descriptionObject



34
35
36
# File 'lib/byebug/commands/restart.rb', line 34

def self.short_description
  'Restarts the debugged program'
end

Instance Method Details

#executeObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/byebug/commands/restart.rb', line 38

def execute
  cmd = [$PROGRAM_NAME]

  cmd = prepend_byebug_bin(cmd)
  cmd = prepend_ruby_bin(cmd)

  cmd += (@match[:args] ? @match[:args].shellsplit : $ARGV)

  puts pr('restart.success', cmd: cmd.shelljoin)
  Kernel.exec(*cmd)
end