Skip to content

Commit

Permalink
Improve unknown command handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cgranleese-r7 committed Feb 8, 2024
1 parent d3bde6b commit e874c1a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/rex/ui/text/dispatcher_shell.rb
Expand Up @@ -588,7 +588,15 @@ def run_command(dispatcher, method, arguments)
# If the command is unknown...
#
def unknown_command(method, line)
print_error("Unknown command: #{method}")
# Map each dispatchers commands to valid_commands
valid_commands = dispatcher_stack.flat_map { |dispatcher| dispatcher.commands.keys }

message = "Unknown command: #{method}."
suggestion = DidYouMean::SpellChecker.new(dictionary: valid_commands).correct(method).first
message << " Did you mean #{suggestion}?" if suggestion
message << ' Run the %grnhelp%clr command for more details.'

print_error(message)
end

#
Expand Down

0 comments on commit e874c1a

Please sign in to comment.