diff options
Diffstat (limited to 'lib/irb/extend-command.rb')
-rw-r--r-- | lib/irb/extend-command.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index 08a258fc53..acc23c9920 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -147,6 +147,20 @@ module IRB # :nodoc: ] + # Convert a command name to its implementation class if such command exists + def self.load_command(command) + command = command.to_sym + @EXTEND_COMMANDS.each do |cmd_name, cmd_class, load_file, *aliases| + next if cmd_name != command && aliases.all? { |alias_name, _| alias_name != command } + + if !defined?(ExtendCommand) || !ExtendCommand.const_defined?(cmd_class, false) + require_relative load_file + end + return ExtendCommand.const_get(cmd_class, false) + end + nil + end + # Installs the default irb commands: # # +irb_current_working_workspace+:: Context#main |