summaryrefslogtreecommitdiff
path: root/lib/irb.rb
AgeCommit message (Collapse)Author
2024-12-14[ruby/irb] Fix broken rdoc-ref caused by a typoStan Lo
(https://github.com/ruby/irb/pull/1049) https://github.com/ruby/irb/commit/cdc88fe87f
2024-12-13[ruby/irb] Avoid generating documentation pages for internalStan Lo
components (https://github.com/ruby/irb/pull/1047) https://github.com/ruby/irb/commit/f57025a35e
2024-11-20[ruby/irb] Move main object's safe call logic to ContextStan Lo
(https://github.com/ruby/irb/pull/1034) https://github.com/ruby/irb/commit/9750fa23cc
2024-11-19[ruby/irb] Don't use delegator to install helper methods to maintomoya ishida
object (https://github.com/ruby/irb/pull/1031) IRB used delegator to install command as a method of frozen main object. Command is not a method now. We can drop it. https://github.com/ruby/irb/commit/2f1c593801
2024-10-18[ruby/irb] Suppress "literal string will be frozen in the future"Tsutomu Katsube
warning (https://github.com/ruby/irb/pull/1019) * Suppress "literal string will be frozen in the future" warning Before change: ```console $ ruby -W -I lib -e 'require "irb"; IRB.setup(nil); IRB::Irb.new.build_statement("1 + 2")' /Users/zzz/src/github.com/ruby/irb/lib/irb.rb:1135: warning: literal string will be frozen in the future ``` After change: ```console $ ruby -W -I lib -e 'require "irb"; IRB.setup(nil); IRB::Irb.new.build_statement("1 + 2")' ``` * Making build_statement not modify the given argument Because improves readability and code quality. Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com> --------- https://github.com/ruby/irb/commit/3da04b9786 Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com>
2024-10-11[ruby/irb] Document infinite historyGert Goet
(https://github.com/ruby/irb/pull/1012) As introduced in 824473e8 https://github.com/ruby/irb/commit/15e3f50c3f
2024-10-11[ruby/irb] History refactors (https://github.com/ruby/irb/pull/1013)Gert Goet
* Extract logic save_history in separate helper * Extract logic history_file in helper * Allow for readonly history https://github.com/ruby/irb/commit/52307f9026
2024-08-27[ruby/irb] Move parse_command method to ContextStan Lo
(https://github.com/ruby/irb/pull/993) Since Context dictates whether a line is a command or an expression, moving the parse_command method to Context makes the relationship more explicit. https://github.com/ruby/irb/commit/9a4487af61
2024-07-16[ruby/irb] Group class methods under `class << self`Stan Lo
(https://github.com/ruby/irb/pull/981) https://github.com/ruby/irb/commit/cdaa356df2
2024-06-30[ruby/irb] Allow assigning and using local variable name conflictingtomoya ishida
with command (https://github.com/ruby/irb/pull/961) https://github.com/ruby/irb/commit/00603d470f
2024-05-04[ruby/irb] Use flag instead of caller for `debug`'s binding.irbStan Lo
check (https://github.com/ruby/irb/pull/947) https://github.com/ruby/irb/commit/4a4d7a4279
2024-05-02Sync IRB 241e061Stan Lo
2024-05-01[ruby/irb] Support `IRB.conf[:BACKTRACE_FILTER]`Stan Lo
(https://github.com/ruby/irb/pull/917) * Use 'irbtest-' instead if 'irb-' as prefix of test files. Otherwise IRB would mis-recognize exceptions raised in test files as exceptions raised in IRB itself. * Support `IRB.conf[:BACKTRACE_FILTER]`` This config allows users to customize the backtrace of exceptions raised and displayed in IRB sessions. This is useful for filtering out library frames from the backtrace. IRB expects the given value to response to `call` method and return the filtered backtrace. https://github.com/ruby/irb/commit/6f6e87d769
2024-04-30[ruby/irb] Restore MAIN_CONTEXT correctlytomoya ishida
(https://github.com/ruby/irb/pull/937) https://github.com/ruby/irb/commit/c41f460a70
2024-04-20[ruby/irb] Stop using ExtendCommandBundle internallyStan Lo
(https://github.com/ruby/irb/pull/925) This module was used to extend both commands and helpers when they're not separated. Now that they are, and we have a Command module, we should move command-related logic to the Command module and update related references. This will make the code easier to understand and refactor in the future. https://github.com/ruby/irb/commit/f74ec97236
2024-04-20[ruby/irb] Remove exit command workaround, handle IRB_EXIT intomoya ishida
debug_readline (https://github.com/ruby/irb/pull/923) * Remove exit and exti! command workaround when executed outside of IRB Command was a method. It could be executed outside of IRB. Workaround for it is no longer needed. * Handle IRB_EXIT in debug mode * Add exit and exit! command in rdbg mode https://github.com/ruby/irb/commit/0b5dd6afd0
2024-04-18[ruby/irb] Fix % escape in prompt formattomoya ishida
(https://github.com/ruby/irb/pull/927) https://github.com/ruby/irb/commit/08eee25d28
2024-04-18[ruby/irb] Prompt specifiers documentation improvementsLorenzo Zabot
(https://github.com/ruby/irb/pull/926) https://github.com/ruby/irb/commit/e8ea8f253d
2024-04-14[ruby/irb] Allow defining custom commands in IRBStan Lo
(https://github.com/ruby/irb/pull/886) This is a feature that has been requested for a long time. It is now possible to define custom commands in IRB. Example usage: ```ruby require "irb/command" class HelloCommand < IRB::Command::Base description "Prints hello world" category "My commands" help_message "It doesn't do more than printing hello world." def execute puts "Hello world" end end IRB::Command.register(:hello, HelloCommand) ``` https://github.com/ruby/irb/commit/888643467c
2024-04-12[ruby/irb] Pass statements to Context#evaluateStan Lo
(https://github.com/ruby/irb/pull/920) This has a few benefits: - We can keep hiding the evaluation logic inside the Context level, which has always been the convention until #824 was merged recently. - Although not an official API, gems like `debug` and `mission_control-jobs` patch `Context#evaluate` to wrap their own logic around it. This implicit contract was broken after #824, and this change restores it. In addition to the refactor, I also converted some context-level evaluation tests into integration tests, which are more robust and easier to maintain. https://github.com/ruby/irb/commit/b32aee4068
2024-04-10[ruby/irb] Add a workaround to make IRB work with debug's testsStan Lo
(https://github.com/ruby/irb/pull/919) https://github.com/ruby/irb/commit/eb442c4dda
2024-04-10[ruby/irb] Command implementation not by methodtomoya ishida
(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> --------- https://github.com/ruby/irb/commit/8fb776e379 Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-04-05[ruby/irb] Filter backtrace before format in handle_exceptionJoshua Broughton
(https://github.com/ruby/irb/pull/916) handle_exception now applies the filter_backtrace to exception backtraces prior to formatting the lines with Exception#full_message This fixes a bug in upstream projects, notably Rails, where the backtrace filtering logic expects the lines to be formatted as Exception#backtrace. https://github.com/ruby/irb/commit/805ee008f9 Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
2024-03-22[ruby/irb] Remove misleading documentationArtur
(https://github.com/ruby/irb/pull/906) https://github.com/ruby/irb/issues/904 https://github.com/ruby/irb/commit/89bca01bba
2024-03-16[ruby/irb] Use markdown format for docsStan Lo
(https://github.com/ruby/irb/pull/890) * Convert irb.rb's document into markdown format * Hide should-be-private top-level methods from docs * Skip xmp.rb's docs * Declare lib/irb.rb's markup do it works in ruby/ruby too * Ignore docs folder https://github.com/ruby/irb/commit/e9a175e06b
2024-03-01[ruby/irb] Restructure workspace managementStan Lo
(https://github.com/ruby/irb/pull/888) * Remove dead irb_level method * Restructure workspace management Currently, workspace is an attribute of IRB::Context in most use cases. But when some workspace commands are used, like `pushws` or `popws`, a workspace will be created and used along side with the original workspace attribute. This complexity is not necessary and will prevent us from expanding multi-workspace support in the future. So this commit introduces a @workspace_stack ivar to IRB::Context so IRB can have a more natural way to manage workspaces. * Fix pushws without args * Always display workspace stack after related commands are used https://github.com/ruby/irb/commit/61560b99b3
2024-02-23[ruby/irb] Remove workaround for empty lines in dynamic_prompttomoya ishida
(https://github.com/ruby/irb/pull/884) https://github.com/ruby/irb/commit/820b9e8dd6
2024-02-23[ruby/irb] Remove remaining `frozen_string_literal: false` in lib/tomoya ishida
(https://github.com/ruby/irb/pull/883) https://github.com/ruby/irb/commit/4bfdb23ae6
2024-02-18[ruby/irb] Revamp `help` commandStan Lo
(https://github.com/ruby/irb/pull/877) * Make help command display help for individual commands Usage: `help [command]` If the command is not specified, it will display a list of all available commands. If the command is specified, it will display the banner OR description of the command. If the command is not found, it will display a message saying that the command is not found. * Rename test/irb/cmd to test/irb/command * Add banner to edit and ls commands * Promote help command in the help message 1. Make `show_cmds` an alias of `help` so it's not displayed in the help message 2. Update description of the help command to reflect `help <command>` syntax * Rename banner to help_message https://github.com/ruby/irb/commit/43a2c99f3f
2024-02-16[ruby/irb] Standardize command related namesStan Lo
(https://github.com/ruby/irb/pull/873) * Replace ExtendCommand with Command and standardize command related names 1. Rename lib/irb/extend-command.rb to lib/irb/command.rb 2. Rename lib/irb/cmd/*.rb to lib/irb/command/*.rb 3. Rename test/irb/test_cmd.rb to test/irb/test_command.rb 4. Rename ExtendCommand to Command * Alias ExtendCommand to Command and deprecate it * Rename Command::Nop to Command::Base * Not deprecate old constants just yet * Add lib/irb/cmd/nop.rb back https://github.com/ruby/irb/commit/462c1284af
2024-02-16[ruby/irb] Support repeating debugger input by passing empty inputStan Lo
to it (https://github.com/ruby/irb/pull/856) * Test IRB's behaviour with empty input * Handle empty input and pass it to debugger Since `rdbg` accepts empty input to repeat the previous command, IRB should take empty input in `irb:rdbg` sessions and pass them to the debugger. Currently, IRB simply ignores empty input and does nothing. This commit creates `EmptyInput` to represent empty input so it can fit into the current IRB's input processing flow in `Irb#eval_input`. https://github.com/ruby/irb/commit/0e9db419be
2024-02-15Do not include a backtick in error messages and backtracesYusuke Endoh
[Feature #16495]
2024-02-12[ruby/irb] Powerup show_source by enabling RubyVM.keep_script_linestomoya ishida
(https://github.com/ruby/irb/pull/862) * Powerup show_source by enabling RubyVM.keep_script_lines * Add file_content field to avoid reading file twice while show_source * Change path passed to eval, don't change irb_path. * Encapsulate source coloring logic and binary file check insode class Source * Add edit command testcase when irb_path does not exist * Memoize irb_path existence to reduce file existence check calculating eval_path https://github.com/ruby/irb/commit/239683a937
2024-02-12[ruby/irb] Fix exit! command warning and method behaviortomoya ishida
(https://github.com/ruby/irb/pull/868) * Fix exit! command warning and method behavior * Remove arg(0) from Kernel.exit and Kernel.exit! https://github.com/ruby/irb/commit/372bc59bf5
2024-02-11[ruby/irb] Polish the exit! command and its testsStan Lo
(https://github.com/ruby/irb/pull/867) * Remove IRB.irb_exit! method It's not necessary to introduce a new method just for the exit! command at this moment. * Rename ExitForcedAction to ForceExit * Move force exit tests to a dedicated file * Fix nested history saving with exit! command Because we switched to use `Kernel#exit` instead of `exit!`, the outer session's ensure block in `Irb#run` will be run, which will save the history. This means the separate check to save history when force exiting is no longer necessary. * execute_lines helper should also capture IRB setup's output This prevents setup warnings from being printed to test output while allowing those output to be tested. * Update readme https://github.com/ruby/irb/commit/899d10ade1
2024-02-10[ruby/irb] Introduce exit! commandIgnacio Chiazzo Cardarello
(https://github.com/ruby/irb/pull/851) * Added failing test for when writing history on exit * Save history on exit * Exit early when calling Kernel.exit * use status 0 for kernel.exit * Added test for nested sessions * Update lib/irb.rb --------- https://github.com/ruby/irb/commit/c0a5f31679 Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-02-01[ruby/irb] Skip re-setup when creating a child sessionNuno Silva
(https://github.com/ruby/irb/pull/850) https://github.com/ruby/irb/commit/06b2d00dd3
2024-01-25[ruby/irb] Reword history file documentation and fix typoEddie Lebow
(https://github.com/ruby/irb/pull/842) https://github.com/ruby/irb/commit/bbabf818c7
2024-01-25[ruby/irb] assigment ==> assignmentydah
https://github.com/ruby/irb/commit/24c7694467
2024-01-25[ruby/irb] reseting ==> resettingydah
https://github.com/ruby/irb/commit/6209f06c72
2024-01-25[ruby/irb] configuation ==> configurationydah
https://github.com/ruby/irb/commit/a27a511777
2024-01-22[ruby/irb] Fix documentation typo, `niL` -> `nil`Eddie Lebow
https://github.com/ruby/irb/commit/79086a9dda
2024-01-06[ruby/irb] Refactor exit commandStan Lo
(https://github.com/ruby/irb/pull/835) * Remove unnecessary code from the exit command's implementation 1. The parameters of `IRB.irb_exit` were never used. But there are some libraries seem to call it with arguments + it's declared on the top-level IRB constant. So I changed the params to anonymous splat instead of removing them. 2. `Context#exit` was completely unnecessary as `IRB.irb_exit` doesn't use the `@irb` instance it passes. And since it's (or should be treated as) a private method, I simply removed it. 3. The `exit` command doesn't use the status argument it receives at all. But to avoid raising errors on usages like `exit 1`, I changed the argument to anonymous splat instead removing it. * Make exit an actual command * Update readme https://github.com/ruby/irb/commit/452b543a65
2023-12-25[ruby/irb] Remove dead doc (https://github.com/ruby/irb/pull/819)Burdette Lamar
https://github.com/ruby/irb/commit/2d5a1afdf5
2023-12-20[ruby/irb] [DOC] Change indexes.rdoc to indexes.mdBurdette Lamar
(https://github.com/ruby/irb/pull/812) * Change indexes.rdoc to indexes.md * Change indexes.rdoc to indexes.md * Change indexes.rdoc to indexes.md https://github.com/ruby/irb/commit/b1cd53cbf7
2023-12-12[ruby/irb] Remove documents about deprecated/WIP features and someStan Lo
slight adjustments (https://github.com/ruby/irb/pull/811) https://github.com/ruby/irb/commit/6a9193e88b
2023-12-12[ruby/irb] Remove trailing spaceStan Lo
This is required to fix ruby/ruby's CI https://github.com/ruby/irb/commit/3c77213209
2023-12-12[ruby/irb] [DOC] RDoc for module IRBBurdette Lamar
(https://github.com/ruby/irb/pull/738) [DOC] RDoc for module IRB https://github.com/ruby/irb/commit/f3a0626298
2023-11-30[ruby/irb] Page evaluation result's outputStan Lo
(https://github.com/ruby/irb/pull/784) * Page evaluation result's output This will make it easier to work with long output that exceeds the terminal's height. * Use consistent TERM in rendering tests This makes sure we get consistent result on all platforms. https://github.com/ruby/irb/commit/4fedce93d3
2023-11-28[ruby/irb] Rescue errors from main.to_s/inspect when formattingKasumi Hanazuki
prompt (https://github.com/ruby/irb/pull/791) Currently, IRB just terminates if `main.to_s` raises while IRB constructs the prompt string. This can easily happen if the user wants to start an IRB session in the instance scope of an uninitialized object, for example: ``` class C def initialize binding.irb @values = [] end def to_s = @values.join(',') # raises if uninitialized end C.new ``` This patch makes IRB rescue from such an exception and displays the class name of the exception instead of `main.to_s` to indicate some error has occurred. We may display more detailed information about the exception, but this patch chooses not to do so because 1) the prompt has limited space, 2) users can evaluate `to_s` in IRB to examine the error if they want, and 3) obtaining the details can also raise, which requires nested exception handling and can be complicated. https://github.com/ruby/irb/commit/412ab26067