Class: Byebug::RestartCommand

Inherits:
Command
  • Object
show all
Includes:
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, #ext_files, #gem_files, #lib_files, #root_path, #test_files

Methods inherited from Command

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

Methods included from Helpers::StringHelper

#camelize, #prettify

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/byebug/commands/restart.rb', line 19

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



15
16
17
# File 'lib/byebug/commands/restart.rb', line 15

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

.short_descriptionObject



30
31
32
# File 'lib/byebug/commands/restart.rb', line 30

def self.short_description
  'Restarts the debugged program'
end

Instance Method Details

#executeObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/byebug/commands/restart.rb', line 34

def execute
  argv = [$PROGRAM_NAME]

  argv.unshift(bin_file) if Byebug.mode == :standalone

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

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