diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-05-25 16:42:38 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-05-25 16:42:38 +0100 |
commit | 3d80b31e028916b325c7884b9ed89bf47e9a1ece (patch) | |
tree | 76ee0eb795aa40bc8eb54b9ec9b0f21bd30991d5 /src/rspamadm/rspamadm.c | |
parent | 2a0c0d92a392b8a6d97e940bde2fdb8565cf2279 (diff) | |
download | rspamd-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.c | 11 |
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); } |