Class: Byebug::RestartCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/byebug/commands/restart.rb

Overview

Restart debugged program from within byebug.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, #match

Methods included from StringFunctions

#camelize, #prettify

Methods included from FileFunctions

#get_line, #get_lines, #n_lines, #normalize

Methods included from ParseFunctions

#get_int, #parse_steps, #syntax_valid?, #without_stderr

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



37
38
39
40
41
42
43
44
# 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

.namesObject



33
34
35
# File 'lib/byebug/commands/restart.rb', line 33

def names
  %w(restart)
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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

#regexpObject



10
11
12
# File 'lib/byebug/commands/restart.rb', line 10

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