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

Improves unknown command handling #18806

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 %grn#{suggestion}%clr?" if suggestion
message << ' Run the %grnhelp%clr command for more details.'

print_error(message)
cgranleese-r7 marked this conversation as resolved.
Show resolved Hide resolved
end

#
Expand Down