aboutsummaryrefslogtreecommitdiffstats
path: root/src/rspamadm/rspamadm.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-25 16:42:38 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-25 16:42:38 +0100
commit3d80b31e028916b325c7884b9ed89bf47e9a1ece (patch)
tree76ee0eb795aa40bc8eb54b9ec9b0f21bd30991d5 /src/rspamadm/rspamadm.c
parent2a0c0d92a392b8a6d97e940bde2fdb8565cf2279 (diff)
downloadrspamd-3d80b31e028916b325c7884b9ed89bf47e9a1ece.tar.gz
rspamd-3d80b31e028916b325c7884b9ed89bf47e9a1ece.zip
[Minor] Suggest command if not found
Diffstat (limited to 'src/rspamadm/rspamadm.c')
-rw-r--r--src/rspamadm/rspamadm.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/rspamadm/rspamadm.c b/src/rspamadm/rspamadm.c
index e20f9ee83..df68f6139 100644
--- a/src/rspamadm/rspamadm.c
+++ b/src/rspamadm/rspamadm.c
@@ -384,7 +384,16 @@ main (gint argc, gchar **argv, gchar **env)
cmd = rspamadm_search_command (cmd_name, all_commands);
if (cmd == NULL) {
- fprintf (stderr, "Invalid command name: %s\n", cmd_name);
+ rspamd_fprintf (stderr, "Invalid command name: %s\n", cmd_name);
+
+ /* Try fuzz search */
+ rspamd_fprintf (stderr, "Suggested commands:\n");
+ PTR_ARRAY_FOREACH (all_commands, i, cmd) {
+ if (rspamd_strings_levenshtein_distance (cmd->name, 0, cmd_name, 0, 1) == 1) {
+ rspamd_fprintf (stderr, "%s\n", cmd->name);
+ }
+ }
+
exit (EXIT_FAILURE);
}