class Byebug::RestartCommand


Restart debugged program from within byebug.

def description

def description
  prettify <<-EOD
    restart|R [args]
    Restart the program. This is a re-exec - all byebug state
    is lost. If command arguments are passed those are used.
  EOD
end

def execute

def execute
  if Byebug.mode == :standalone
    cmd = "#{Gem.bin_path('byebug', 'byebug')} #{$PROGRAM_NAME}"
  else
    cmd = $PROGRAM_NAME
  end
  if @match[:args]
    cmd += " #{@match[:args]}"
  else
    require 'shellwords'
    cmd += " #{$ARGV.compact.shelljoin}"
  end
  puts pr('restart.success', cmd: cmd)
  exec(cmd)
end

def names

def names
  %w(restart)
end

def regexp

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