class Byebug::RestartCommand - byebug-4.0.5 Documentation

# class Byebug::RestartCommand

Restart debugged program from within byebug.

### Public Class Methods

description() click to toggle source

    # File lib/byebug/commands/restart.rb, line 37
    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

names() click to toggle source

    # File lib/byebug/commands/restart.rb, line 33
    def names
      %w(restart)
    end

### Public Instance Methods

execute() click to toggle source

    # File lib/byebug/commands/restart.rb, line 14
    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

regexp() click to toggle source

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