# class Byebug::RestartCommand

Restart debugged program from within byebug.

### Public Class Methods

description() click to toggle source

    # 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

regexp() click to toggle source

    # File lib/byebug/commands/restart.rb, line 21
    def self.regexp
      /^\s* restart (?:\s+(?<args>.+))? \s*$/x
    end

short_description() click to toggle source

    # File lib/byebug/commands/restart.rb, line 36
    def self.short_description
      "Restarts the debugged program"
    end

### Public Instance Methods

execute() click to toggle source

    # 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

### Private Instance Methods

prepend_byebug_bin(cmd) click to toggle source

    # File lib/byebug/commands/restart.rb, line 54
    def prepend_byebug_bin(cmd)
      cmd.unshift(bin_file) if Byebug.mode == :standalone
      cmd
    end

prepend_ruby_bin(cmd) click to toggle source

    # File lib/byebug/commands/restart.rb, line 59
    def prepend_ruby_bin(cmd)
      cmd.unshift(RbConfig.ruby) if which("ruby") != which(cmd.first)
      cmd
    end