diff options
Diffstat (limited to 'lib/irb')
-rw-r--r-- | lib/irb/cmd/show_cmds.rb | 6 | ||||
-rw-r--r-- | lib/irb/context.rb | 14 | ||||
-rw-r--r-- | lib/irb/init.rb | 4 |
3 files changed, 19 insertions, 5 deletions
diff --git a/lib/irb/cmd/show_cmds.rb b/lib/irb/cmd/show_cmds.rb index 7d6b3ec266..a8d899e4ac 100644 --- a/lib/irb/cmd/show_cmds.rb +++ b/lib/irb/cmd/show_cmds.rb @@ -16,6 +16,12 @@ module IRB commands_info = IRB::ExtendCommandBundle.all_commands_info commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] } + user_aliases = irb_context.instance_variable_get(:@user_aliases) + + commands_grouped_by_categories["Aliases"] = user_aliases.map do |alias_name, target| + { display_name: alias_name, description: "Alias for `#{target}`" } + end + if irb_context.with_debugger # Remove the original "Debugging" category commands_grouped_by_categories.delete("Debugging") diff --git a/lib/irb/context.rb b/lib/irb/context.rb index a7b8ca2c26..3442fbf4da 100644 --- a/lib/irb/context.rb +++ b/lib/irb/context.rb @@ -146,9 +146,21 @@ module IRB @newline_before_multiline_output = true end - @command_aliases = IRB.conf[:COMMAND_ALIASES] + @user_aliases = IRB.conf[:COMMAND_ALIASES].dup + @command_aliases = @user_aliases.merge(KEYWORD_ALIASES) end + # because all input will eventually be evaluated as Ruby code, + # command names that conflict with Ruby keywords need special workaround + # we can remove them once we implemented a better command system for IRB + KEYWORD_ALIASES = { + :break => :irb_break, + :catch => :irb_catch, + :next => :irb_next, + }.freeze + + private_constant :KEYWORD_ALIASES + private def build_completor completor_type = IRB.conf[:COMPLETOR] case completor_type diff --git a/lib/irb/init.rb b/lib/irb/init.rb index 9704e36cb1..b69f68d530 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -189,10 +189,6 @@ module IRB # :nodoc: # Symbol aliases :'$' => :show_source, :'@' => :whereami, - # Keyword aliases - :break => :irb_break, - :catch => :irb_catch, - :next => :irb_next, } end |