]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] rspamadm control: list commands when none/unknown is given
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 8 May 2026 07:20:43 +0000 (08:20 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 8 May 2026 07:20:43 +0000 (08:20 +0100)
Previously `rspamadm control` (no args) just printed "command required"
and exited, forcing users to dig through `rspamadm help control` to
discover the available subcommands. List them inline on the no-arg and
unknown-command error paths, matching the help output.

src/rspamadm/control.c

index 1a7d67c7fa10cffb658dd2df0761276f1c914d64..e90697702e3ce2ef0ba8e47a32add0d46df57cff 100644 (file)
@@ -63,6 +63,17 @@ static GOptionEntry entries[] = {
         "Set IO timeout (1s by default)", NULL},
        {NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
 
+#define RSPAMADM_CONTROL_COMMAND_LIST                                  \
+       "Supported commands:\n"                                            \
+       "  stat            - show statistics\n"                            \
+       "  reload          - reload workers dynamic data\n"                \
+       "  reresolve       - resolve upstreams addresses\n"                \
+       "  recompile       - recompile hyperscan regexes\n"                \
+       "  fuzzystat       - show fuzzy statistics\n"                      \
+       "  fuzzysync       - immediately sync fuzzy database to storage\n" \
+       "  compositesstats - show composites processing statistics\n"      \
+       "  memstat         - show memory usage statistics across all workers\n"
+
 static const char *
 rspamadm_control_help(gboolean full_help, const struct rspamadm_command *cmd)
 {
@@ -77,16 +88,7 @@ rspamadm_control_help(gboolean full_help, const struct rspamadm_command *cmd)
                                   "-u: output ucl (default)\n"
                                   "-s: use the following socket instead of " RSPAMD_DBDIR "/rspamd.sock\n"
                                   "-t: set IO timeout (1.0 seconds default)\n"
-                                  "--help: shows available options and commands\n\n"
-                                  "Supported commands:\n"
-                                  "stat - show statistics\n"
-                                  "reload - reload workers dynamic data\n"
-                                  "reresolve - resolve upstreams addresses\n"
-                                  "recompile - recompile hyperscan regexes\n"
-                                  "fuzzystat - show fuzzy statistics\n"
-                                  "fuzzysync - immediately sync fuzzy database to storage\n"
-                                  "compositesstats - show composites processing statistics\n"
-                                  "memstat - show memory usage statistics across all workers\n";
+                                  "--help: shows available options and commands\n\n" RSPAMADM_CONTROL_COMMAND_LIST;
        }
        else {
                help_str = "Manage rspamd main control interface";
@@ -203,7 +205,8 @@ rspamadm_control(int argc, char **argv, const struct rspamadm_command *_cmd)
        g_option_context_free(context);
 
        if (argc <= 1) {
-               rspamd_fprintf(stderr, "command required\n");
+               rspamd_fprintf(stderr,
+                                          "command required\n\n" RSPAMADM_CONTROL_COMMAND_LIST);
                exit(EXIT_FAILURE);
        }
 
@@ -238,7 +241,9 @@ rspamadm_control(int argc, char **argv, const struct rspamadm_command *_cmd)
                path = "/memstat";
        }
        else {
-               rspamd_fprintf(stderr, "unknown command: %s\n", cmd);
+               rspamd_fprintf(stderr,
+                                          "unknown command: %s\n\n" RSPAMADM_CONTROL_COMMAND_LIST,
+                                          cmd);
                exit(EXIT_FAILURE);
        }