class Byebug::RestartCommand


Restart debugged program from within byebug.

def self.description

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

def self.regexp

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

def self.short_description

def self.short_description
  "Restarts the debugged program"
end

def execute

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

def prepend_byebug_bin(cmd)

def prepend_byebug_bin(cmd)
  cmd.unshift(bin_file) if Byebug.mode == :standalone
  cmd
end

def prepend_ruby_bin(cmd)

def prepend_ruby_bin(cmd)
  cmd.unshift(RbConfig.ruby) if which("ruby") != which(cmd.first)
  cmd
end