diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-09-25 01:26:29 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-09-25 01:26:29 +0100 |
commit | 219288ea4ffd24399d110b28ff790bcf78eb6532 (patch) | |
tree | c00316e87eeb2a452588a499e1eb11f8140beaf7 | |
parent | 8d08ce4da42d2b746a7462899f901e8f422e3d81 (diff) | |
download | rspamd-219288ea4ffd24399d110b28ff790bcf78eb6532.tar.gz rspamd-219288ea4ffd24399d110b28ff790bcf78eb6532.zip |
Slightly improve help messages.
-rw-r--r-- | src/rspamadm/configtest.c | 8 | ||||
-rw-r--r-- | src/rspamadm/keypair.c | 8 | ||||
-rw-r--r-- | src/rspamadm/pw.c | 4 | ||||
-rw-r--r-- | src/rspamadm/rspamadm.c | 41 |
4 files changed, 40 insertions, 21 deletions
diff --git a/src/rspamadm/configtest.c b/src/rspamadm/configtest.c index bfcce0413..1e70f1cc0 100644 --- a/src/rspamadm/configtest.c +++ b/src/rspamadm/configtest.c @@ -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 { diff --git a/src/rspamadm/keypair.c b/src/rspamadm/keypair.c index 746a9c294..d5ef2bce4 100644 --- a/src/rspamadm/keypair.c +++ b/src/rspamadm/keypair.c @@ -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 { diff --git a/src/rspamadm/pw.c b/src/rspamadm/pw.c index df1ca2db7..f72db4fa3 100644 --- a/src/rspamadm/pw.c +++ b/src/rspamadm/pw.c @@ -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"; diff --git a/src/rspamadm/rspamadm.c b/src/rspamadm/rspamadm.c index d052dd054..3698366ae 100644 --- a/src/rspamadm/rspamadm.c +++ b/src/rspamadm/rspamadm.c @@ -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]; |