Skip to content

Conversation

jethrodaniel
Copy link
Contributor

@jethrodaniel jethrodaniel commented Jun 26, 2025

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 jethrodaniel marked this pull request as ready for review June 26, 2025 22:17
@jethrodaniel
Copy link
Contributor Author

CI failures seem unrelated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant