summaryrefslogtreecommitdiff
path: root/lib/irb/cmd
AgeCommit message (Collapse)Author
2024-03-26[ruby/irb] Fix a typo (https://github.com/ruby/irb/pull/912)Hiroshi SHIBATA
https://github.com/ruby/irb/commit/2057248e40
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-14[ruby/irb] Repurpose the help command to display the help messageStan Lo
(https://github.com/ruby/irb/pull/872) See #787 for more details. https://github.com/ruby/irb/commit/d9192d92d0
2024-02-13[ruby/irb] Fix SourceFinder's constant evaluation issueStan Lo
(https://github.com/ruby/irb/pull/869) Currently, if the signature's constant part is not defined, a NameError would be raised. ``` irb(main):001> show_source Foo (eval):1:in `<top (required)>': uninitialized constant Foo (NameError) Foo ^^^ from (irb):1:in `<main>' ``` This commit fixes the issue and simplifies the `edit` command's implementation. https://github.com/ruby/irb/commit/8c16e029d1
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-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-13[ruby/irb] Warn and do nothing if block is passed to measure commandtomoya ishida
(https://github.com/ruby/irb/pull/813) https://github.com/ruby/irb/commit/e79a90a1e6
2023-12-10[ruby/irb] Simplify show_source's super calculationStan Lo
(https://github.com/ruby/irb/pull/807) https://github.com/ruby/irb/commit/2cccc448de
2023-12-07[ruby/irb] Debugging command warning should not be specific to theStan Lo
`debug` command (https://github.com/ruby/irb/pull/806) https://github.com/ruby/irb/commit/b7b57311cc
2023-12-02[ruby/irb] Implement `history` commandGary Tou
(https://github.com/ruby/irb/pull/761) * Implement `history` command Lists IRB input history with indices. Also aliased as `hist`. * Add tests for `history` command * Address feedback: `puts` with multiple arguments instead of `join`ing * Address feedback: Handle nil from splitting an empty input string * Refactor line truncation * Add `-g` grep option to `history` command * Add `history` command to README * Remove unused `*args` parameter * Allow spaces to be included in grep * Allow `/` to be included in grep regex * Handle `input` being an empty string * Exclude "#{index}: " from matching the grep regex * Add new line after joining https://github.com/ruby/irb/commit/3f9eacbfa9
2023-11-28[ruby/irb] This enhancement allows a user to add the -s flag if theypaulreece
want to access a methods origin definition. It allows for chaining of multiple esses to further go up the classes as needed. (https://github.com/ruby/irb/pull/770) https://github.com/ruby/irb/commit/eec1329d5a
2023-11-26[ruby/irb] Display aliases in help messageStan Lo
(https://github.com/ruby/irb/pull/788) Similar to Pry, it displays user-defined aliases in the help message with a dedicated section. With the current default aliases, it looks like: ``` ...other sections... Aliases $ Alias for `show_source` @ Alias for `whereami` ``` https://github.com/ruby/irb/commit/2a0eacc891
2023-11-08[ruby/irb] Type based completion using Prism and RBStomoya ishida
(https://github.com/ruby/irb/pull/708) * Add completor using prism and rbs * Add TypeCompletion test * Switchable completors: RegexpCompletor and TypeCompletion::Completor * Add completion info to irb_info * Complete reserved words * Fix [*] (*) {**} and prism's change of KeywordParameterNode * Fix require, frozen_string_literal * Drop prism<=0.16.0 support * Add Completor.last_completion_error for debug report * Retrieve `self` and `Module.nesting` in more safe way * Support BasicObject * Handle lvar and ivar get exception correctly * Skip ivar reference test of non-self object in ruby < 3.2 * BaseScope to RootScope, move method objects constant under Methods * Remove unused Splat struct * Drop deeply nested array/hash type calculation from actual object. Now, calculation depth is 1 * Refactor loading rbs in test, change preload_in_thread not to cache Thread object * Use new option added in prism 0.17.1 to parse code with localvars * Add Prism version check and warn when :type completor cannot be enabled * build_type_completor should skip truffleruby (because endless method definition is not supported) https://github.com/ruby/irb/commit/1048c7ed7a
2023-09-22[ruby/irb] Page show_source's outputStan Lo
(https://github.com/ruby/irb/pull/719) https://github.com/ruby/irb/commit/3cedc5cb62
2023-08-29[ruby/irb] Improve help/show_cmds message during debuggerStan Lo
integration (https://github.com/ruby/irb/pull/693) * `help` should display debugger's help during irb:rdbg session * Update `show_cmds`'s output when in irb:rdbg session https://github.com/ruby/irb/commit/4029c2e564
2023-08-20[ruby/irb] Support `VISUAL` env var, and prefer it over `EDITOR`Summer ☀️
(https://github.com/ruby/irb/pull/686) * Support `VISUAL` env var, and prefer it over `EDITOR` * Update test/irb/test_cmd.rb --------- https://github.com/ruby/irb/commit/399b872c31 Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-08-13[ruby/irb] Support seamless integration with ruby/debugStan Lo
(https://github.com/ruby/irb/pull/575) * Support native integration with ruby/debug * Prevent using multi-irb and activating debugger at the same time Multi-irb makes a few assumptions: - IRB will manage all threads that host sub-irb sessions - All IRB sessions will be run on the threads created by IRB itself However, when using the debugger these assumptions are broken: - `debug` will freeze ALL threads when it suspends the session (e.g. when hitting a breakpoint, or performing step-debugging). - Since the irb-debug integration runs IRB as the debugger's interface, it will be run on the debugger's thread, which is not managed by IRB. So we should prevent the 2 features from being used at the same time. To do that, we check if the other feature is already activated when executing the commands that would activate the other feature. https://github.com/ruby/irb/commit/d8fb3246be
2023-08-02[ruby/irb] Deprecate multi-irb commandsStan Lo
(https://github.com/ruby/irb/pull/654) * Deprecate multi-irb commands - Print deprecated message when any of the commands are used - Put related commands under `Multi-irb` category with a deprecated label * Update readme https://github.com/ruby/irb/commit/861731ac12
2023-08-01[ruby/irb] Add workspace categoryStan Lo
(https://github.com/ruby/irb/pull/661) * Create a new Workspace command category * Update readme https://github.com/ruby/irb/commit/310650c213
2023-07-31[ruby/irb] Decouple `edit` and `show_source` commandsStan Lo
(https://github.com/ruby/irb/pull/658) * Decouple `edit` command from `show_source` 2 commands should not depend on each other. If `edit` command also needs to find a source, the source finding logic should be extracted into a separate class. * Return nil if is not an actual file path * Refactor SourceFinder https://github.com/ruby/irb/commit/9790517a0c
2023-07-26[ruby/irb] Page `ls`'s output (https://github.com/ruby/irb/pull/657)Stan Lo
* Page ls command's output * Use Pager.page_content in show_cmds too https://github.com/ruby/irb/commit/82d1687302
2023-07-25[ruby/irb] Display `show_cmds`'s output in a pager when in TTYStan Lo
environment (https://github.com/ruby/irb/pull/647) This can: - Make it easier to scroll up and down the commands list - Avoid pushing up users' previous output - Allow users to do basic search with `/<word>` https://github.com/ruby/irb/commit/f94e8a66dd
2023-07-04[ruby/irb] Use `max_by` for `longest_cmd_name_length`Andy Waite
(https://github.com/ruby/irb/pull/628) https://github.com/ruby/irb/commit/5e87f3bfdd Co-authored-by: Andy Waite <andyw8@users.noreply.github.com>
2023-06-25[ruby/irb] Fix process_continue(rename to should_continue?) andtomoya ishida
check_code_block(rename to check_code_syntax) (https://github.com/ruby/irb/pull/611) https://github.com/ruby/irb/commit/b7f4bfaaa4
2023-06-10[ruby/irb] Remove the unused fork command definitionStan Lo
(https://github.com/ruby/irb/pull/600) https://github.com/ruby/irb/commit/b039b89343
2023-06-05[ruby/irb] Refactor ExtendCommand::NopStan Lo
(https://github.com/ruby/irb/pull/598) * Rename conf to irb_context * Drop Nop#irb method because it's only used by irb/ext/loader.rb We don't need to expose this method to all command classes, especially when it's just an alias of `irb_context.irb`.
2023-06-05[ruby/irb] Simplify irb_info commandStan Lo
(https://github.com/ruby/irb/pull/597) https://github.com/ruby/irb/commit/0a0409c52b
2023-05-23[ruby/irb] Allow `show_source` for private methodsTSUYUSATO Kitsune
(https://github.com/ruby/irb/pull/589) * Allow `show_source` for private methods Fix https://github.com/ruby/irb/pull/577 * Pend tests on TruffleRuby It seems `eval(..., __LINE__ + 1)` does not work. Other similar tests are also pended on TruffleRuby, so I think it is acceptable. * Use `private_method_defined?` instead of `defined?`
2023-05-18[ruby/irb] Print deprecation warning for `help` commandStan Lo
(https://github.com/ruby/irb/pull/567) * Give show_doc its own command class * Print deprecation warning for `help` command
2023-04-24[ruby/irb] Simplify the help command's implementationStan Lo
(https://github.com/ruby/irb/pull/564) The current method-redefining approach brings little benefit, makes it harder to understand the code, and causes warnings like: > warning: method redefined; discarding old execute This patch simplifies it while displaying more helpful message when rdoc couldn't be loaded.
2023-04-24[ruby/irb] Filter out top-level methods when using `lsStan Lo
<Class/Module>` (https://github.com/ruby/irb/pull/562) Instead of always printing methods inherited from Class or Module, IRB by default should filter them out unless `<Class/Module>` is specified to be either of those.
2023-04-05[ruby/irb] Drop Ruby 2.6 supportStan Lo
(https://github.com/ruby/irb/pull/555) * Remove all Ruby 2.6 support * Drop Ruby 2.6 specific testing conditions * Only run Ruby 2.7+ on CI * Bump Ruby requirement to 2.7+ https://github.com/ruby/irb/commit/3f714b616c
2023-04-02[ruby/irb] Don't check RUBY_ENGINE when deciding whether to accept kargsStan Lo
Ruby implementations like JRuby and TruffleRuby already indicate their compatibility target with RUBY_VERSION. We don't need to exclude them from accepting keyword arguments as long as they target 2.7+. https://github.com/ruby/irb/commit/bf20faa4e6 Co-authored-by: Kevin Menard <kevin@nirvdrum.com>
2023-02-28[ruby/irb] Display and prioritise instance methods in `lsStan Lo
<module/class>` (https://github.com/ruby/irb/pull/496) https://github.com/ruby/irb/commit/e3d21f9329
2023-01-14[ruby/irb] Store context in RubyLexStan Lo
Some background for this refactor: 1. Through a RubyLex instance's lifetime, the context passed to its methods should be the same. Given that `Context` is only initialised in `Irb#initialize`, this should be true. 2. When `RubyLex` is initialised, the context object should be accessible. This is also true in all 3 of `RubyLex.new`'s invocations. With the above observations, we should be able to store the context in `RubyLex` as an instance variable. And doing so will make `RubyLex`'s instance methods easier to use and maintain. https://github.com/ruby/irb/commit/5c8d3df2df
2023-01-11[ruby/irb] Formatting to header stylesHiroshi SHIBATA
https://github.com/ruby/irb/commit/cef125850d
2023-01-11[ruby/irb] Removed Release Version and Revisions for old VCS softwareHiroshi SHIBATA
https://github.com/ruby/irb/commit/07fae94862
2022-12-20[ruby/irb] Respect DLEXT to force-load debug.soTakashi Kokubun
(https://github.com/ruby/irb/pull/481) Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-12-12[ruby/irb] `show_doc` command should take non-string argument tooStan Lo
(https://github.com/ruby/irb/pull/478) Given that `show_doc` already supports syntax like `String#gsub`, it should be able to take it in non-string form too, like `edit` and `show_source` do. This ensures users can have a consistent syntax on argument between different commands.
2022-12-09[ruby/irb] Fix step command (https://github.com/ruby/irb/pull/477)Stan Lo
The current `next` pre-command workaround on IRB source stepping moves the location by 1 extra line. A better way is to make `debug` skip IRB frames completely, which is what this commit does. It also fixes the step command's test. The `|` in regexp was not escaped so it was always incorrectly matched.
2022-12-08[ruby/irb] Gracefully handle missing command argumentStan Lo
(https://github.com/ruby/irb/pull/473) * Handle file loading commands' argument error gracefully Currently, if users don't provide an argument to `source`, `irb_load`, and `irb_require`, IRB raises `ArgumentError` with full stacktrace. This is confusing because it looks similar to when IRB has internal issues. The message also isn't helpful on helping users avoid the error. So in this commit, I add a new `CommandArgumentError` for commands to raise explicitly when users' input doesn't satisfy a command's argument requirement. * Gracefully handle `fg` command's argument requirement
2022-12-08[ruby/irb] Add "show_cmds" command to list all commands'Stan Lo
descriptions (https://github.com/ruby/irb/pull/463) https://github.com/ruby/irb/commit/7e857655ac
2022-12-07[ruby/irb] Lazily load the multi-irb extensionStan Lo
(https://github.com/ruby/irb/pull/472) * Lazily load the multi-irb extension We now have plan to implement a command that prints all commands' information, which will need to load all command files without actually running them. But because the `multi-irb` extension patches IRB's top-level methods, loading it would cause unintentional side-effects. So this commit moves related requires into command execution to avoid the problem. * Make extend_irb_context private Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2022-11-30[ruby/irb] Make sure ls doesn't return an arrayTakashi Kokubun
(https://github.com/ruby/irb/pull/461) https://github.com/ruby/irb/commit/367797bb05
2022-11-28[ruby/irb] Fix the debug.gem force-loader for Ruby 3.2Takashi Kokubun
(https://github.com/ruby/irb/pull/458) * Fix the debug.gem force-loader for Ruby 3.2 * Support 1.7.0dev format as well
2022-11-21[ruby/irb] Add commands to start and use the debuggerTakashi Kokubun
(https://github.com/ruby/irb/pull/449) * Seamlessly integrate a few debug commands * Improve the break command support * Utilize skip_src option if available * Add step and delete commands * Write end-to-end tests for each debugger command * Add documentation * Add backtrace, info, catch commands https://github.com/ruby/irb/commit/976100c1c2
2022-11-20[ruby/irb] Add edit command (https://github.com/ruby/irb/pull/453)Stan Lo
* Add edit command * Make find_source a public singleton method * Add document for the edit command * Make find_end private * Remove duplicated private https://github.com/ruby/irb/commit/4321674aa7 Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>