Sha256: 7b4ef4a5e3507f6b4d5147b4aed6ed50bf09daae989b0ce6765c3d75b9272d52

Contents?: true

Size: 937 Bytes

Versions: 10

Compression:

Stored size: 937 Bytes

Contents

require 'byebug/command'
require 'byebug/helpers/path'
require 'shellwords'

module Byebug
  #
  # Restart debugged program from within byebug.
  #
  class RestartCommand < Command
    include Helpers::PathHelper

    self.allow_in_control = true
    self.allow_in_post_mortem = true

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

    def self.description
      <<-EOD
        restart [args]

        #{short_description}

        This is a re-exec - all byebug state is lost. If command arguments are
        passed those are used.
      EOD
    end

    def self.short_description
      'Restarts the debugged program'
    end

    def execute
      argv = [$PROGRAM_NAME]

      argv.unshift(bin_file) if Byebug.mode == :standalone

      argv += (@match[:args] ? @match[:args].shellsplit : $ARGV.compact)

      puts pr('restart.success', cmd: argv.shelljoin)
      Kernel.exec(*argv)
    end
  end
end

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/byebug-9.0.6/lib/byebug/commands/restart.rb
tdiary-5.0.5 vendor/bundle/gems/byebug-9.0.6/lib/byebug/commands/restart.rb
tdiary-5.0.4 vendor/bundle/gems/byebug-9.0.6/lib/byebug/commands/restart.rb
byebug-9.0.6 lib/byebug/commands/restart.rb
byebug-9.0.5 lib/byebug/commands/restart.rb
byebug-9.0.4 lib/byebug/commands/restart.rb
byebug-9.0.3 lib/byebug/commands/restart.rb
byebug-9.0.2 lib/byebug/commands/restart.rb
byebug-9.0.1 lib/byebug/commands/restart.rb
byebug-9.0.0 lib/byebug/commands/restart.rb