Sha256: 42cbbd016745c3caad50da43e463413fbe497dd3ed984f3ead56f20e19e9b189

Contents?: true

Size: 981 Bytes

Versions: 1

Compression:

Stored size: 981 Bytes

Contents

# frozen_string_literal: true

module RubyJard
  module Commands
    # Command used to explore stacktrace.
    class FrameCommand < Pry::ClassCommand
      include RubyJard::Commands::ValidationHelpers

      group 'RubyJard'
      description 'Explore to any frame of current stacktrace.'

      match 'frame'

      banner <<-BANNER
      Usage: frame [FRAME_ID]

      Explore to any frame of current stacktrace.

      Examples:
        frame 4 # Jump to frame 4 in the backtrace
      BANNER

      def initialize(context = {})
        super(context)
        @session = context[:session] || RubyJard.current_session
      end

      def process
        frame = validate_present!(args.first)
        frame = validate_non_negative_integer!(frame)
        frame = validate_range!(frame, 0, @session.current_backtrace.length - 1)
        RubyJard::ControlFlow.dispatch(:frame, frame: frame)
      end
    end
  end
end

Pry::Commands.add_command(RubyJard::Commands::FrameCommand)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby_jard-0.2.3 lib/ruby_jard/commands/frame_command.rb