Conversation
st0012
commented
Feb 23, 2024
6defafa to
f43f1fb
Compare
f43f1fb to
f6f50a3
Compare
Member
|
I think this is basically OK 👍 What do you think? I think I'm ready with #824 that fixes #592. I don't want to make |
36ee6c5 to
b074da4
Compare
Member
Author
|
@tompng I've rebased the PR and made a few more improvements. Can you give it another look? |
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)
```
b074da4 to
06a295d
Compare
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Apr 14, 2024
(ruby/irb#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) ``` ruby/irb@888643467c
tenderlove
added a commit
to tenderlove/ruby
that referenced
this pull request
Apr 15, 2024
* master: (29 commits) Not all `nm`s support the `--help` option Emit a performance warning when redefining specially optimized methods YJIT: A64: Avoid intermediate register in `opt_and` and friends (ruby#10509) [ruby/reline] Remove not implemented method (ruby/reline#680) [ruby/reline] Fix vi_to_column which was broken (ruby/reline#679) Include more debug information in test_uplus_minus [Universal parser] DeVALUE of p->debug_lines and ast->body.script_lines Add more assertions in `test_uplus_minus` `super{}` doesn't use block fix incorrect warning. Update default gems list at fc36394 [ci skip] [ruby/optparse] bump up to 0.5.0 show warning for unused block Emit `warn` event for duplicated hash keys on ripper [ruby/reline] Refactored Default Key Bindings (ruby/reline#678) [ruby/reline] Refactor waiting_proc and waiting_operator_proc (ruby/reline#649) [pty] Fix missing `or` [pty] Fix `ptsname_r` fallback [ruby/irb] Allow defining custom commands in IRB (ruby/irb#886) [ruby/reline] Support `menu-complete-backward` command for upward navigation (ruby/reline#677) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This is a feature that has been requested for a long time. It is now possible to define custom commands in IRB.
Example usage:
And the command will appear in the help message:
Details
lib/irb/default_commands.rbso requiringirb/commandis very lightweight.CommandAPIs are introducedCommand.register(command_name, command_class)is the official API to register a command. I decided not to accept alias for now as the current aliasing mechanism is messy.Command._register_with_aliases(name, command_class, *aliases)is an internal API for IRB to register its existing commands and their aliases.Command.commandsto get all the registered commandsI think this is should probably be introduced before #624 because:
Closes #513