ruby/lib/irb/command/whereami.rb
tomoya ishida 6a505d1b59 [ruby/irb] Command implementation not by method
(https://github.com/ruby/irb/pull/824)

* Command is not a method

* Fix command test

* Implement non-method command name completion

* Add test for ExtendCommandBundle.def_extend_command

* Add helper method install test

* Remove spaces in command input parse

* Remove command arg unquote in help command

* Simplify Statement and handle execution in IRB::Irb

* Tweak require, const name

* Always install CommandBundle module to main object

* Remove considering local variable in command or expression check

* Remove unused method, tweak

* Remove outdated comment for help command arg

Co-authored-by: Stan Lo <stan001212@gmail.com>

---------

8fb776e379

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-04-10 16:52:53 +00:00

23 lines
435 B
Ruby

# frozen_string_literal: true
module IRB
# :stopdoc:
module Command
class Whereami < Base
category "Context"
description "Show the source code around binding.irb again."
def execute(_arg)
code = irb_context.workspace.code_around_binding
if code
puts code
else
puts "The current context doesn't have code."
end
end
end
end
# :startdoc:
end