From b5527e009f372d9908065150d04056c9d451122e Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 19 Nov 2022 00:14:00 -0800 Subject: [PATCH 1/3] Document a full list of commands --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ lib/irb.rb | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/README.md b/README.md index b2405bed7..e137cd4ea 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,48 @@ irb(main):006:1> end The Readline extension module can be used with irb. Use of Readline is default if it's installed. +## Commands + +The following commands are available on IRB. + +* `cwws` + * Show the current workspace. +* `cb`, `cws`, `chws` + * Change the current workspace to an object. +* `bindings`, `workspaces` + * Show workspaces. +* `pushb`, `pushws` + * Push an object to the workspace stack. +* `popb`, `popws` + * Pop a workspace from the workspace stack. +* `load` + * Load a Ruby file. +* `require` + * Require a Ruby file. +* `source` + * Loads a given file in the current session. +* `irb` + * Start a child IRB. +* `jobs` + * List of current sessions. +* `fg` + * Switches to the session of the given number. +* `kill` + * Kills the session with the given number. +* `help` + * Enter the mode to look up RI documents. +* `irb_info` + * Show information about IRB. +* `ls` + * Show methods, constants, and variables. + `-g [query]` or `-G [query]` allows you to filter out the output. +* `measure` + * `measure` enables the mode to measure processing time. `measure :off` disables it. +* `$`, `show_source` + * Show the source code of a given method or constant. +* `@`, `whereami` + * Show the source code around binding.irb again. + ## Documentation https://docs.ruby-lang.org/en/master/IRB.html diff --git a/lib/irb.rb b/lib/irb.rb index 64da85215..047179668 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -53,6 +53,48 @@ # # :include: ./irb/lc/help-message # +# == Commands +# +# The following commands are available on IRB. +# +# * cwws +# * Show the current workspace. +# * cb, cws, chws +# * Change the current workspace to an object. +# * bindings, workspaces +# * Show workspaces. +# * pushb, pushws +# * Push an object to the workspace stack. +# * popb, popws +# * Pop a workspace from the workspace stack. +# * load +# * Load a Ruby file. +# * require +# * Require a Ruby file. +# * source +# * Loads a given file in the current session. +# * irb +# * Start a child IRB. +# * jobs +# * List of current sessions. +# * fg +# * Switches to the session of the given number. +# * kill +# * Kills the session with the given number. +# * help +# * Enter the mode to look up RI documents. +# * irb_info +# * Show information about IRB. +# * ls +# * Show methods, constants, and variables. +# -g [query] or -G [query] allows you to filter out the output. +# * measure +# * measure enables the mode to measure processing time. measure :off disables it. +# * $, show_source +# * Show the source code of a given method or constant. +# * @, whereami +# * Show the source code around binding.irb again. +# # == Configuration # # IRB reads a personal initialization file when it's invoked. From 96aba1c5e0705986dd8c5a75ab75c5424dc222e8 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 19 Nov 2022 14:13:30 -0800 Subject: [PATCH 2/3] Document debug as well --- README.md | 2 ++ lib/irb.rb | 2 ++ lib/irb/extend-command.rb | 1 + 3 files changed, 5 insertions(+) diff --git a/README.md b/README.md index e137cd4ea..821d97ec2 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,8 @@ The following commands are available on IRB. * Show the source code of a given method or constant. * `@`, `whereami` * Show the source code around binding.irb again. +* `debug` + * Start the debugger of debug.gem. ## Documentation diff --git a/lib/irb.rb b/lib/irb.rb index 047179668..6e74e5395 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -94,6 +94,8 @@ # * Show the source code of a given method or constant. # * @, whereami # * Show the source code around binding.irb again. +# * debug +# * Start the debugger of debug.gem. # # == Configuration # diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index 7da75fe14..3d892b708 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -185,6 +185,7 @@ def self.load_command(command) # +irb_measure+:: IRB::unset_measure_callback # +irb_show_source+:: #find_source, #show_source # +irb_whereami+:: Workspace#code_around_binding + # +irb_debug+:: #debugger def self.install_extend_commands for args in @EXTEND_COMMANDS def_extend_command(*args) From ad677d1f629beb030e19882dbb350cd70c68350d Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 19 Nov 2022 14:14:01 -0800 Subject: [PATCH 3/3] Make it less duplicated --- lib/irb/extend-command.rb | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index 3d892b708..94fd9c8bb 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -165,27 +165,7 @@ def self.load_command(command) nil end - # Installs the default irb commands: - # - # +irb_current_working_workspace+:: Context#main - # +irb_change_workspace+:: Context#change_workspace - # +irb_workspaces+:: Context#workspaces - # +irb_push_workspace+:: Context#push_workspace - # +irb_pop_workspace+:: Context#pop_workspace - # +irb_load+:: #irb_load - # +irb_require+:: #irb_require - # +irb_source+:: IrbLoader#source_file - # +irb+:: IRB.irb - # +irb_jobs+:: JobManager - # +irb_fg+:: JobManager#switch - # +irb_kill+:: JobManager#kill - # +irb_help+:: IRB@Command+line+options - # +irb_info+:: #inspect - # +irb_ls+:: Output#dump - # +irb_measure+:: IRB::unset_measure_callback - # +irb_show_source+:: #find_source, #show_source - # +irb_whereami+:: Workspace#code_around_binding - # +irb_debug+:: #debugger + # Installs the default irb commands. def self.install_extend_commands for args in @EXTEND_COMMANDS def_extend_command(*args)