Sha256: dc2c5afb34108ae0475b8335be3f24d2b9052311559d0207409a7d042dd3e089

Contents?: true

Size: 948 Bytes

Versions: 8

Compression:

Stored size: 948 Bytes

Contents

require 'byebug/command'

module Byebug
  #
  # Restart debugged program from within byebug.
  #
  class RestartCommand < Command
    self.allow_in_control = true

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

    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

    class << self
      def names
        %w(restart)
      end

      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
    end
  end
end

Version data entries

8 entries across 7 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/byebug-4.0.5/lib/byebug/commands/restart.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/byebug-4.0.5/lib/byebug/commands/restart.rb
byebug-4.0.5 lib/byebug/commands/restart.rb
byebug-4.0.4 lib/byebug/commands/restart.rb
byebug-4.0.3 lib/byebug/commands/restart.rb
byebug-4.0.2 lib/byebug/commands/restart.rb
byebug-4.0.1 lib/byebug/commands/restart.rb
byebug-4.0.0 lib/byebug/commands/restart.rb