irb icon indicating copy to clipboard operation
irb copied to clipboard

whereami: support -f to show the full file like pry

Open jethrodaniel opened this issue 5 months ago • 1 comments

Support passing -f to whereami to show the full file, like pry does.

[!NOTE] I added support for -f, but not for --file, since the only other IRB command I see that has flags only supports short forms (history).

I haven't personally ever used --file.

Here's pry's help page for comparison:

% pry
[1] pry(main)> help whereami                                                                                     
Usage: whereami [-qn] [LINES]

Describe the current location. If you use `binding.pry` inside a method then
whereami will print out the source for that method.

If a number is passed, then LINES lines before and after the current line will be
shown instead of the method itself.

The `-q` flag can be used to suppress error messages in the case that there's
no code to show. This is used by pry in the default before_session hook to show
you when you arrive at a `binding.pry`.

The `-n` flag can be used to hide line numbers so that code can be copy/pasted
effectively.

When pry was started on an Object and there is no associated method, whereami
will instead output a brief description of the current object.

    -q, --quiet                Don't display anything in case of an error
    -n, --no-line-numbers      Do not display line numbers
    -m, --method               Show the complete source for the current method.
    -c, --class                Show the complete source for the current class or module.
    -f, --file                 Show the complete source for the current file.
    -h, --help                 Show this message.
[2] pry(main)> Pry::VERSION                                                                                      
=> "0.14.2"

Thanks for IRB, btw!

jethrodaniel avatar Jun 26 '25 22:06 jethrodaniel

CI failures seem unrelated.

jethrodaniel avatar Jun 26 '25 22:06 jethrodaniel