LoginSignup
4
2

More than 5 years have passed since last update.

pryのhelpでpryの概要を知る

Posted at

前置き

Ruby の REPL ではもう irb じゃなく pry を使うのがフツーになってると思います。
ただ、非常に多機能なため、ほとんどの機能を使わずに利用していることが多いと思います。

pry の機能をくわしく紹介してくださってるのが

なのですが、やはり多機能すぎて、あまり良く見渡せない。
もっと簡単な地図は無いのか。

本編

すごく単純な事なのですが、やはり help にはそのコマンドの簡単な内容が載ってますよね。
私自身が今まで見たことが無かったのに、今回見てみたら簡潔に纏まっていたので、ご紹介したいと思ったわけです(といってもやはり多いですねw)。
以下のメッセージは

[1]pry(main)> help

で返ってくるものを若干編集したものです。

1. Help

help               Show a list of commands or information about a specific command.

2. Context

cd                 Move into a new context (object or scope).
find-method        Recursively search for a method within a class/module or the current namespace.
ls                 Show the list of vars and methods in the current scope.
pry-backtrace      Show the backtrace for the pry session.
raise-up           Raise an exception out of the current pry instance.
reset              Reset the repl to a clean state.
watch              Watch the value of an expression and print a notification whenever it changes.
whereami           Show code surrounding the current context.      (Alias: @)
wtf?               Show the backtrace of the most recent exception.

3. Editing

/^\s*!\s*$/        Clear the input buffer.
amend-line         Amend a line of input in multi-line mode.
edit               Invoke the default editor on a file.
hist               Show and replay readline history.        (Alias: history)
play               Playback a string variable, method, line, or file as input.
show-input         Show the contents of the input buffer for the current multi-line expression.

4. Introspection

ri                 View ri documentation.
show-doc           Show the documentation for a method or class. (Alias: ?)
show-source        Show the source for a method or class.        (Alias: $, show-method)
stat               View method information and set _file_ and _dir_ locals.

5. Gems

gem-cd             Change working directory to specified gem's directory.
gem-install        Install a gem and refresh the gem cache.
gem-list           List and search installed gems.
gem-open           Opens the working directory of the gem in your editor.

6. Commands

import-set         Import a pry command set.
install-command    Install a disabled command.

7. Input and output

.<shell command>   All text following a '.' is forwarded to the shell.
cat                Show code from a file, pry's input buffer, or the last exception.
change-inspector   Change the current inspector proc.
change-prompt      Change the current prompt.
fix-indent         Correct the indentation for contents of the input buffer
list-inspectors    List the inspector procs available for use.
list-prompts       List the prompts available for use.
save-file          Export to a file using content from the repl.
shell-mode         Toggle shell mode. bring in pwd prompt and file completion. (Alias: file-mode)

8. Misc

gist               Upload code, docs, history to https://gist.github.com/.
clipit             Alias for `gist --clip`
pry-version        Show pry version.
reload-code        Reload the source file that contains the specified code object. (Alias: reload-method)
toggle-color       Toggle syntax highlighting.

9. Navigating pry

!pry               Start a pry session on current self.
disable-pry        Stops all future calls to pry and exits the current session.
exit               Pop the previous binding.    (Alias: quit)
exit-all           End the current pry session. (Alias: !!@)
exit-program       End the current program.     (Alias: !!!, quit-program)
jump-to            Jump to a binding further up the stack.
nesting            Show nesting information.
switch-to          Start a new subsession on a binding in the current stack.

10. Prompts

simple-prompt      Toggle the simple prompt.

gist コマンドなんて初めて見ました。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2