Граф коммитов

967 Коммитов

Автор SHA1 Сообщение Дата
Stan Lo abaa1b913d [ruby/irb] Bump version to v1.14.0
(https://github.com/ruby/irb/pull/980)

https://github.com/ruby/irb/commit/6a9e129714
2024-07-06 17:55:00 +00:00
Stan Lo 32ba86c9be [ruby/irb] Return only commands when completing help command's
argument
(https://github.com/ruby/irb/pull/973)

The command only takes command names as arguments, so we should only
return command names as candidates.

This will help users find a command faster as completion will be
another useful hint too.

https://github.com/ruby/irb/commit/7b6557cc24
2024-07-05 17:51:17 +00:00
Stan Lo 7fe5f0a1d0 [ruby/irb] Introduce cd command
(https://github.com/ruby/irb/pull/971)

It's essentially a combination of pushws and popws commands that are
easier to use.

Help message:

```
Usage: cd ([target]|..)

IRB uses a stack of workspaces to keep track of context(s), with `pushws` and `popws` commands to manipulate the stack.
The `cd` command is an attempt to simplify the operation and will be subject to change.

When given:
- an object, cd will use that object as the new context by pushing it onto the workspace stack.
- "..", cd will leave the current context by popping the top workspace off the stack.
- no arguments, cd will move to the top workspace on the stack by popping off all workspaces.

Examples:

  cd Foo
  cd Foo.new
  cd @ivar
  cd ..
  cd
```

https://github.com/ruby/irb/commit/4a0e0e89b7
2024-07-03 17:17:42 +00:00
Stan Lo 921f22e563 [ruby/irb] Improve how command calls' return value is handled
(https://github.com/ruby/irb/pull/972)

In #934, we changed command calls to return nil only. This PR improves
the behaviour even further by:

- Not echoing the `nil` returned by command calls
- Not overriding previous return value stored in `_` with the
  `nil` from commands

https://github.com/ruby/irb/commit/c844176842
2024-06-18 15:15:23 +00:00
Stan Lo ce6a1ba9a1 [ruby/irb] Bump version to v1.13.2
(https://github.com/ruby/irb/pull/970)

https://github.com/ruby/irb/commit/35de7dacd4
2024-06-15 20:14:01 +00:00
Stan Lo aa61d4237d [ruby/irb] Add accidentally dropped disable_irb command back
(https://github.com/ruby/irb/pull/964)

* Add accidentally dropped disable_irb command back

* Sort command files require by name

https://github.com/ruby/irb/commit/1d627cebca
2024-06-05 16:29:29 +00:00
tomoya ishida a8c1ef6a60 [ruby/irb] Remove useless Reline::Key.new and update wrong comment
for alt+d
(https://github.com/ruby/irb/pull/963)

https://github.com/ruby/irb/commit/a572180b3a
2024-06-04 12:09:15 +00:00
Kevin Newton 84d2bacb42 [ruby/irb] Reorder ruby lex clauses for unrecoverable first
(https://github.com/ruby/irb/pull/956)

When a syntax error includes multiple error messages, we want to
check for unrecoverable messages first so that we do not
accidentally match a recoverable error later in the message.

https://github.com/ruby/irb/commit/2f42b2360d
2024-05-17 02:44:57 +00:00
Stan Lo c68bb24088 [ruby/irb] Add a new initialization step to validate IRB.conf's
values
(https://github.com/ruby/irb/pull/953)

Currently, users can only find out that they have set a wrong value
for IRB configs when the value is used, with opaque error messages like
"comparison of Integer with true failed (TypeError)".

This commit adds a new initialization step to validate the values of
some IRB configs, so that users can find out about the wrong values
during the initialization of IRB.

https://github.com/ruby/irb/commit/af8ef2948b
2024-05-10 11:40:58 +00:00
Kevin Newton 69d0a3b033 [ruby/irb] Simplify regexp to account for prism error messages
(https://github.com/ruby/irb/pull/954)

https://github.com/ruby/irb/commit/e0c29be074

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-05-10 09:39:11 +00:00
Stan Lo 93cffcf961 [ruby/irb] Bump version to v1.13.1
(https://github.com/ruby/irb/pull/951)

https://github.com/ruby/irb/commit/66318d0a34
2024-05-05 11:11:31 +00:00
Stan Lo e973f9cbb3 [ruby/irb] Clarify that the context is IRB context
(https://github.com/ruby/irb/pull/950)

https://github.com/ruby/irb/commit/8cde57f55a
2024-05-05 10:44:52 +00:00
tomoya ishida 96710a3139 [ruby/irb] Change debug test workaround only enabled when output is
tty
(https://github.com/ruby/irb/pull/949)

https://github.com/ruby/irb/commit/3f231b8622
2024-05-04 09:03:55 +00:00
Stan Lo bd42f0898d [ruby/irb] Improve help message for no meta commands
(https://github.com/ruby/irb/pull/948)

* Remove unnecessary code from command tests

* Improve help message for no meta commands

1. Add placeholder values for both command category and description
2. Update help command's output to give different types of categories
   more explicit ordering

https://github.com/ruby/irb/commit/b1ef58aeff
2024-05-04 03:32:34 +00:00
Stan Lo fb2ea7084f [ruby/irb] Use flag instead of caller for `debug`'s binding.irb
check
(https://github.com/ruby/irb/pull/947)

https://github.com/ruby/irb/commit/4a4d7a4279
2024-05-04 03:22:17 +00:00
Kenichi Kamiya a510175e8f [ruby/irb] Avoid raising errors while running help for custom
commands
(https://github.com/ruby/irb/pull/944)

* Avoid raising errors while running help for custom commands

Raising an error from the help command is not a pleasure for the
end user, even if the command does not define any attributes

* Update test/irb/command/test_custom_command.rb

---------

https://github.com/ruby/irb/commit/c8bba9f8dc

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-05-03 22:08:49 +00:00
Stan Lo 945a99e81a Sync IRB 241e061 2024-05-02 14:33:30 -04:00
tomoya ishida 032070d793 [ruby/irb] Add workaround for ruby/debug/test/console/irb_test
failing with StdioInputMethod
(https://github.com/ruby/irb/pull/943)

https://github.com/ruby/irb/commit/acf3c1816e
2024-05-02 16:21:46 +00:00
Stan Lo fef6f5f2e1 [ruby/irb] Bump version to v1.13.0
(https://github.com/ruby/irb/pull/941)

* Bump version to v1.13.0

* Add Documentation category to changelog

https://github.com/ruby/irb/commit/b9b1f35c99
2024-05-01 15:20:01 +00:00
tomoya ishida 77f5301cd1 [ruby/irb] Let IRB::Color.colorable? always return true|false
(https://github.com/ruby/irb/pull/940)

https://github.com/ruby/irb/commit/0bbe435ffe
2024-05-01 14:52:53 +00:00
Stan Lo 148518baa0 [ruby/irb] Suppress command return values
(https://github.com/ruby/irb/pull/934)

Since commands can't be chained with methods, their return values are
not intended to be used. But if IRB keeps storing command return values
as the last value, and print them, users may rely on such implicit
behaviour.

So to avoid such confusion, this commit suppresses command's
return values. It also updates some commands that currently rely on
this implicit behaviour.

https://github.com/ruby/irb/commit/fa96bea76f
2024-04-26 17:52:12 +00:00
Stan Lo 25a8b76c76 [ruby/irb] Command registration should take both strings and symbols
as names
(https://github.com/ruby/irb/pull/932)

This will save users some heads scratching when they try to register a
command with a string name and found that it doesn't work.

I also rewrote converted custom command tests into integration tests to
make test setup/cleanup easier.

https://github.com/ruby/irb/commit/a91a212dbe
2024-04-26 12:12:31 +00:00
Stan Lo 4349c7909f [ruby/irb] Memoize helper method instances with Singleton module
(https://github.com/ruby/irb/pull/931)

Some helpers, like Rails console's `app`, requires memoization of the
helper's ivars. To support it IRB needs to memoize helper method instances
as well.

https://github.com/ruby/irb/commit/a96c7a6668
2024-04-24 18:32:55 +00:00
Stan Lo 9bba999be7 [ruby/irb] Revert "Memoize helper method instances with Singleton module"
This reverts commit https://github.com/ruby/irb/commit/169a9a2c3097.

https://github.com/ruby/irb/commit/221b0a4928
2024-04-24 16:01:23 +00:00
Stan Lo e5ca3d072f [ruby/irb] Memoize helper method instances with Singleton module
Some helpers, like Rails console's `app`, requires memoization of the
helper's ivars. To support it IRB needs to memoize helper method instances
as well.

https://github.com/ruby/irb/commit/169a9a2c30
2024-04-24 16:01:02 +00:00
Stan Lo e11237904c
Sync IRB f9347b1 (#10611) 2024-04-23 21:00:56 +00:00
Stan Lo f16c6ac4fd [ruby/irb] Stop using ExtendCommandBundle internally
(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 18:55:54 +00:00
tomoya ishida 125e1ed5f7 [ruby/irb] Remove exit command workaround, handle IRB_EXIT in
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-20 07:45:41 +00:00
tomoya ishida ca764062b0 [ruby/irb] Remove internal-only methods from Command::Base
(https://github.com/ruby/irb/pull/922)

* Remove internal-only methods from Command::Base

Command#ruby_args and Command#unwrap_string_literal are used for default command's argument backward compatibility.
Moved these methods to another module to avoid being used from custom commands.

* Update lib/irb/command/edit.rb

---------

https://github.com/ruby/irb/commit/7405a841e8

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-04-17 18:36:30 +00:00
Stan Lo 04ba96e619 [ruby/irb] Allow defining custom commands in IRB
(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-14 11:01:43 +00:00
Stan Lo f1d9e895b9 [ruby/irb] Pass statements to Context#evaluate
(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-12 12:01:03 +00:00
Stan Lo d75dc39880 [ruby/irb] Centralize rstrip calls
(https://github.com/ruby/irb/pull/918)

https://github.com/ruby/irb/commit/97898b6251
2024-04-10 17:33:44 +00:00
tomoya ishida 6a505d1b59 [ruby/irb] Command implementation not by method
(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-10 16:52:53 +00:00
Hiroshi SHIBATA 8cfa8e87b2 [ruby/irb] Fix a typo (https://github.com/ruby/irb/pull/912)
https://github.com/ruby/irb/commit/2057248e40
2024-03-26 11:30:33 +00:00
tomoya ishida f53209f023 [ruby/irb] Cache RDoc::RI::Driver.new
(https://github.com/ruby/irb/pull/911)

* Cache RDoc::RI::Driver.new to improve performance and to avoid flaky test

* Insert sleep to fix flaky rendering test that renders document dialog

https://github.com/ruby/irb/commit/da84e6cb56
2024-03-25 11:48:11 +00:00
OKURA Masafumi e6487a9263 [ruby/irb] docs(help): Add latest options to ja help message
(https://github.com/ruby/irb/pull/903)

https://github.com/ruby/irb/commit/3c6d452495
2024-03-18 02:37:42 +00:00
tomoya ishida bda5b09937 [ruby/irb] Fix irb_history saved to current directory
(https://github.com/ruby/irb/pull/901)

* Always save irb_history in HOME or XDG_CONFIG_HOME

Also split irbrc search logic from irb_history search logic as a refactor

* Remove IRB.conf[:RC_NAME_GENERATOR] because it's not configurable

This conf is used to specify which irbrc to load. Need to configure before irbrc is loaded, so it's actually not configurable.
This conf is also used for history file search, but it is configurable by conf[:HISTORY_FILE].

* remove rc_file_test because it is tested with rc_files, remove useless test setup

* Make internal irbrc searching method private

https://github.com/ruby/irb/commit/11d03a6ff7
2024-03-16 15:20:03 +00:00
Stan Lo 137b52a881 [ruby/irb] Use markdown format for docs
(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-16 13:51:07 +00:00
Go d10afe0357 [ruby/irb] Rescue from exceptions raised by #name
(https://github.com/ruby/irb/pull/899)

* Rescue from exceptions raised by #name

Irb might terminate if the class overwrites `name` and raise errors. This commit rescue irb from termination.

* fix for other unknown patterns

https://github.com/ruby/irb/commit/35b87cf893
2024-03-14 15:41:03 +00:00
hogelog 3822ca9884 [ruby/irb] Add disable_irb command to disable debug of binding.irb
(https://github.com/ruby/irb/pull/898)

* Add disable_irb command to disable debug of binding.irb

* disable_irb doesn't override Kernel.exit

Kernel.exit call is removed because disable_irb does not override Kernel.exit
and workaround to https://bugs.ruby-lang.org/issues/18234 is not needed.

https://github.com/ruby/irb/commit/29901e4f21
2024-03-14 15:40:27 +00:00
alpaca-tc e8f796e954 [ruby/irb] rdoc version lock is required
(https://github.com/ruby/irb/pull/897)

Some features of irb do not work properly when using the old rdoc.
I have compared several major versions and found that it works as intended from 4.0.0.

This problem occurs when there is a Gemfile.lock is installed with the old rdoc.
I don't know why this Gemfile.lock installs an older rdoc than the ruby bundled rdoc,
but specifying the version in the gemspec will at least prevent the problem.

NOTE: ruby/irb#704 problem does not occur with this change.

The following is test code.

```
 ### Usage: ruby __FILE__.rb
 # # input RDoc and Tab
 # >> RDoc<Tab>
 #
 ### Expect: Display document of RDoc
 ### Actual: <internal:marshal>:34:in `load': instance of RDoc::Constant needs to have method `marshal_load' (TypeError)
require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
  gem 'irb'
  # gem 'rdoc', '~> 4.0.0'
  gem 'rdoc', '~> 3.12.0'
end

require 'rdoc'
require 'irb'

IRB.start
```

https://github.com/ruby/irb/commit/1a1fbba020
2024-03-08 09:23:40 +00:00
Stan Lo 9fcb2bd5c0 [ruby/irb] Bump version to v1.12.0
(https://github.com/ruby/irb/pull/895)

https://github.com/ruby/irb/commit/a79e84a692
2024-03-07 02:14:44 +00:00
Haroon Ahmed 8f6113a91e [ruby/irb] Add the ability to fetch and load multiple irb files.
(https://github.com/ruby/irb/pull/859)

This allows hierarchy when loading rc files for example both files below
are loaded;

project/.irbrc
~/.irbrc

https://github.com/ruby/irb/commit/b53ebc6655

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-03-05 16:07:45 +00:00
Stan Lo 57ca5960ad [ruby/irb] Restructure workspace management
(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-03-01 15:51:29 +00:00
Stan Lo c976cb52a2 [ruby/irb] Add help messages to `show_source` and `show_doc`
commands
(https://github.com/ruby/irb/pull/887)

* Add help message to the show_source command

* Add help message to the show_doc command

https://github.com/ruby/irb/commit/06f43aadb3
2024-02-25 15:22:33 +00:00
Stan Lo 898f30f8bd [ruby/irb] Refactor IRB::Context#prompting
(https://github.com/ruby/irb/pull/889)

https://github.com/ruby/irb/commit/7b323ee514
2024-02-25 15:21:00 +00:00
tomoya ishida ea2fb7460e [ruby/irb] Remove useless loaded file check
(https://github.com/ruby/irb/pull/885)

https://github.com/ruby/irb/commit/f6d489658e
2024-02-23 13:11:20 +00:00
tomoya ishida 598b03648f [ruby/irb] Remove remaining `frozen_string_literal: false` in lib/
(https://github.com/ruby/irb/pull/883)

https://github.com/ruby/irb/commit/4bfdb23ae6
2024-02-23 12:32:50 +00:00
Stan Lo 4831bb5bab [ruby/irb] Turn on frozen literal in files
(https://github.com/ruby/irb/pull/881)

https://github.com/ruby/irb/commit/83d90550c2
2024-02-23 10:53:53 +00:00
Stan Lo 37dde6e2f8 [ruby/irb] Unroll extension method generation
(https://github.com/ruby/irb/pull/882)

* Unroll extension method generation

Given we only have 2 remaining extension setter methods, both of which
only take 1 argument and don't have any alias, the current method generation
logic is overly complicated.

This commit simplifies the method generation logic by simply defining
the methods directly in the `IRB::Context` class.

* Fix use_loader extension

https://github.com/ruby/irb/commit/67eba5401b
2024-02-23 10:02:19 +00:00