Sha256: 3fabbeb79e1a6995af2f9e61634a2a5c047a588deebaf7f1a71d9050d52a770f

Contents?: true

Size: 1.3 KB

Versions: 6489

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require_relative "../command"
require_relative "../helpers/bin"
require_relative "../helpers/path"
require "shellwords"
require "English"
require "rbconfig"

module Byebug
  #
  # Restart debugged program from within byebug.
  #
  class RestartCommand < Command
    include Helpers::BinHelper
    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
      <<-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.short_description
      "Restarts the debugged program"
    end

    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

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

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

Version data entries

6,489 entries across 6,486 versions & 29 rubygems

Version Path
ory-client-1.15.13 vendor/bundle/ruby/3.1.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
affixapi-1.1.102 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_bank_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_organization_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_id_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_bank_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_organization_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_id_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_id_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_bank_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_organization_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_organization_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_id_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_bank_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_bank_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_id_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_organization_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb
cybrid_api_bank_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/restart.rb