]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix rspamc --commands
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 13 Nov 2016 13:03:35 +0000 (13:03 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 13 Nov 2016 13:04:26 +0000 (13:04 +0000)
src/client/rspamc.c

index 33d49345aefde1a8a5450f1138ff94378204cae9..ea10034377ac6756ed56bfca963191df07b79d26 100644 (file)
@@ -432,16 +432,31 @@ static void
 print_commands_list (void)
 {
        guint i;
+       guint cmd_len = 0;
+       gchar fmt_str[32];
 
        rspamd_fprintf (stdout, "Rspamc commands summary:\n");
+
+       for (i = 0; i < G_N_ELEMENTS (rspamc_commands); i++) {
+               gsize clen = strlen (rspamc_commands[i].name);
+
+               if (clen > cmd_len) {
+                       cmd_len = clen;
+               }
+       }
+
+       rspamd_snprintf (fmt_str, sizeof (fmt_str), "  %%%ds (%%7s%%1s)\t%%s\n",
+                       cmd_len);
+
        for (i = 0; i < G_N_ELEMENTS (rspamc_commands); i++) {
-               rspamd_fprintf (stdout,
-                       "  %10s (%7s%1s)\t%s\n",
-                       rspamc_commands[i].name,
-                       rspamc_commands[i].is_controller ? "control" : "normal",
-                       rspamc_commands[i].is_privileged ? "*" : "",
-                       rspamc_commands[i].description);
+               fprintf (stdout,
+                               fmt_str,
+                               rspamc_commands[i].name,
+                               rspamc_commands[i].is_controller ? "control" : "normal",
+                               rspamc_commands[i].is_privileged ? "*" : "",
+                               rspamc_commands[i].description);
        }
+
        rspamd_fprintf (stdout,
                "\n* is for privileged commands that may need password (see -P option)\n");
        rspamd_fprintf (stdout,