Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid raising errors while running help for custom commands #944

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/irb/command/help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def execute(command_name)
help_message
else
if command_class = Command.load_command(command_name)
command_class.help_message || command_class.description
command_class.help_message || command_class.description || ""
else
"Can't find command `#{command_name}`. Please check the command name and try again.\n\n"
end
Expand Down
26 changes: 26 additions & 0 deletions test/irb/command/test_custom_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,31 @@ def execute(*)
assert_include(output, "2 FooBar executed")
assert_include(output, "foobar_description")
end

def test_no_meta_command_also_works
write_ruby <<~RUBY
require "irb/command"

class NoMetaCommand < IRB::Command::Base
def execute(*)
puts "This command does not override meta attributes"
nil
end
end

IRB::Command.register(:no_meta, NoMetaCommand)

binding.irb
RUBY

output = run_ruby_file do
type "no_meta\n"
type "help no_meta\n"
type "exit"
end

assert_include(output, "This command does not override meta attributes")
assert_not_include(output, "Maybe IRB bug")
end
end
end
Loading