Commit graph

9 commits

Author SHA1 Message Date
tomoya ishida
a542479a75 [ruby/irb] Remove KEYWORD_ALIASES which handled special alias name
of irb_break irb_catch and irb_next command
(https://github.com/ruby/irb/pull/1004)

* Remove KEYWORD_ALIASES which handled special alias name of irb_break irb_catch and irb_next command

* Remove unused instance variable user_aliases

Co-authored-by: Stan Lo <stan001212@gmail.com>

---------

f256d7899f

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-09-12 15:04:37 +00:00
Stan Lo
4a4e1bf357 [ruby/irb] Group class methods under class << self
(https://github.com/ruby/irb/pull/981)

cdaa356df2
2024-07-16 15:58:15 +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
```

4a0e0e89b7
2024-07-03 17:17:42 +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

1d627cebca
2024-06-05 16:29:29 +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.

a91a212dbe
2024-04-26 12:12:31 +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.

f74ec97236
2024-04-20 18:55:54 +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

---------

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)
```

888643467c
2024-04-14 11:01:43 +00:00