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

#executable_file_extensions, #find_executable, #real_executable?, #search_paths, #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



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

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

    #{short_description}

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

.regexpObject



21
22
23
# File 'lib/byebug/commands/restart.rb', line 21

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

.short_descriptionObject



36
37
38
# File 'lib/byebug/commands/restart.rb', line 36

def self.short_description
  "Restarts the debugged program"
end

Instance Method Details

#executeObject



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

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