]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Slightly improve help messages.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 25 Sep 2015 00:26:29 +0000 (01:26 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 25 Sep 2015 00:26:29 +0000 (01:26 +0100)
src/rspamadm/configtest.c
src/rspamadm/keypair.c
src/rspamadm/pw.c
src/rspamadm/rspamadm.c

index bfcce0413cdf4087bb8848c8ed27424b143f7ad4..1e70f1cc01d750997857a5e19824781f1d6e0444 100644 (file)
@@ -59,11 +59,11 @@ rspamadm_configtest_help (gboolean full_help)
        const char *help_str;
 
        if (full_help) {
-               help_str = "Perform configuration file test\n"
+               help_str = "Perform configuration file test\n\n"
                                "Usage: rspamadm configtest [-q -c <config_name>]\n"
-                               "Where options are:\n"
-                               "-q quiet output\n"
-                               "-c config file to test\n"
+                               "Where options are:\n\n"
+                               "-q: quiet output\n"
+                               "-c: config file to test\n"
                                "--help: shows available options and commands";
        }
        else {
index 746a9c2945d654865653f583b4016f0cc6986347..d5ef2bce47d465cb5ef5246345eb52cc84262e4f 100644 (file)
@@ -55,11 +55,11 @@ rspamadm_keypair_help (gboolean full_help)
        const char *help_str;
 
        if (full_help) {
-               help_str = "Create key pairs for httpcrypt\n"
+               help_str = "Create key pairs for httpcrypt\n\n"
                                "Usage: rspamadm keypair [-x -r]\n"
-                               "Where options are:\n"
-                               "-x encode with hex instead of base32\n"
-                               "-r print raw base32/hex\n"
+                               "Where options are:\n\n"
+                               "-x: encode with hex instead of base32\n"
+                               "-r: print raw base32/hex\n"
                                "--help: shows available options and commands";
        }
        else {
index df1ca2db70710921d3c44a79429eb24fdd541522..f72db4fa3732b2b7f4eb50429c715cb9afd56fd0 100644 (file)
@@ -62,9 +62,9 @@ rspamadm_pw_help (gboolean full_help)
        const char *help_str;
 
        if (full_help) {
-               help_str = "Manipulate with passwords in rspamd\n"
+               help_str = "Manipulate with passwords in rspamd\n\n"
                                "Usage: rspamadm pw [command]\n"
-                               "Where commands are:\n"
+                               "Where commands are:\n\n"
                                "--encrypt: encrypt password (this is a default command)\n"
                                "--check: check encrypted password using encrypted password\n"
                                "--help: shows available options and commands";
index d052dd054e9688b614a4213a901b7743b08966ab..3698366ae9a47c18dc618cefa5c17b32db0f04f2 100644 (file)
@@ -72,7 +72,6 @@ static void
 rspamadm_version (void)
 {
        printf ("Rspamadm %s\n", RVERSION);
-       exit (EXIT_SUCCESS);
 }
 
 static void
@@ -82,12 +81,10 @@ rspamadm_usage (GOptionContext *context)
 
        help_str = g_option_context_get_help (context, TRUE, NULL);
        printf ("%s", help_str);
-
-       exit (EXIT_SUCCESS);
 }
 
 static void
-rspamadm_commands (GOptionContext *context)
+rspamadm_commands ()
 {
        const struct rspamadm_command **cmd;
 
@@ -98,11 +95,11 @@ rspamadm_commands (GOptionContext *context)
        cmd = commands;
 
        while (*cmd) {
-               printf ("  %-18s %-60s\n", (*cmd)->name, (*cmd)->help (FALSE));
+               if (!((*cmd)->flags & RSPAMADM_FLAG_NOHELP)) {
+                       printf ("  %-18s %-60s\n", (*cmd)->name, (*cmd)->help (FALSE));
+               }
                cmd ++;
        }
-
-       exit (EXIT_SUCCESS);
 }
 
 static const char *
@@ -125,13 +122,17 @@ static void
 rspamadm_help (gint argc, gchar **argv)
 {
        const gchar *cmd_name;
-       const struct rspamadm_command *cmd;
+       const struct rspamadm_command *cmd, **cmd_list;
+
+       printf ("Rspamadm %s\n", RVERSION);
+       printf ("Usage: rspamadm [global_options] command [command_options]\n\n");
 
-       if (argc == 0) {
+       if (argc <= 1) {
                cmd_name = "help";
        }
        else {
                cmd_name = argv[1];
+               printf ("Showing help for %s command\n\n", cmd_name);
        }
 
        cmd = rspamadm_search_command (cmd_name);
@@ -141,7 +142,22 @@ rspamadm_help (gint argc, gchar **argv)
                exit (EXIT_FAILURE);
        }
 
-       printf ("%s\n", cmd->help (TRUE));
+       if (strcmp (cmd_name, "help") == 0) {
+               printf ("Available commands:\n");
+
+               cmd_list = commands;
+
+               while (*cmd_list) {
+                       if (!((*cmd_list)->flags & RSPAMADM_FLAG_NOHELP)) {
+                               printf ("  %-18s %-60s\n", (*cmd_list)->name,
+                                               (*cmd_list)->help (FALSE));
+                       }
+                       cmd_list++;
+               }
+       }
+       else {
+               printf ("%s\n", cmd->help (TRUE));
+       }
 }
 
 static gboolean
@@ -253,12 +269,15 @@ main (gint argc, gchar **argv, gchar **env)
 
        if (show_version) {
                rspamadm_version ();
+               exit (EXIT_SUCCESS);
        }
        if (show_help) {
                rspamadm_usage (context);
+               exit (EXIT_SUCCESS);
        }
        if (list_commands) {
-               rspamadm_commands (context);
+               rspamadm_commands ();
+               exit (EXIT_SUCCESS);
        }
 
        cmd_name = argv[nargc];