diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-28 17:39:41 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-28 17:39:41 +0000 |
commit | caa742d7a2a5d22acc7e0543a6787abe5d8c853b (patch) | |
tree | 4ee6bd4c7c06a58ecb4fc664803cc07764cf2c46 /src/rspamadm | |
parent | 236f6315e0b30c7f2126f19aa37fc2e5c39e9fb1 (diff) | |
download | rspamd-caa742d7a2a5d22acc7e0543a6787abe5d8c853b.tar.gz rspamd-caa742d7a2a5d22acc7e0543a6787abe5d8c853b.zip |
Implement very basic documentation for options
Diffstat (limited to 'src/rspamadm')
-rw-r--r-- | src/rspamadm/confighelp.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/rspamadm/confighelp.c b/src/rspamadm/confighelp.c index d4ead3ef0..f19f7c92c 100644 --- a/src/rspamadm/confighelp.c +++ b/src/rspamadm/confighelp.c @@ -75,7 +75,7 @@ rspamadm_confighelp_help (gboolean full_help) } static void -rspamadm_confighelp_show (const ucl_object_t *obj) +rspamadm_confighelp_show (const char *key, const ucl_object_t *obj) { rspamd_fstring_t *out; @@ -89,10 +89,18 @@ rspamadm_confighelp_show (const ucl_object_t *obj) } else { /* TODO: add lua helper for output */ + if (key) { + rspamd_fprintf (stdout, "Showing help for %s:\n", key); + } + else { + rspamd_fprintf (stdout, "Showing help for all options:\n"); + } + rspamd_ucl_emit_fstring (obj, UCL_EMIT_CONFIG, &out); } rspamd_fprintf (stdout, "%V", out); + rspamd_fprintf (stdout, "\n"); rspamd_fstring_free (out); } @@ -129,14 +137,18 @@ rspamadm_confighelp (gint argc, gchar **argv) if (argc > 1) { while (argc > 1) { - doc_obj = ucl_lookup_path (cfg->doc_strings, argv[i]); - - if (doc_obj != NULL) { - rspamadm_confighelp_show (doc_obj); - } - else { - rspamd_fprintf (stderr, "Cannot find help for %s\n", argv[i]); - ret = EXIT_FAILURE; + if (argv[i][0] != '-') { + doc_obj = ucl_lookup_path (cfg->doc_strings, argv[i]); + + if (doc_obj != NULL) { + rspamadm_confighelp_show (argv[i], doc_obj); + } + else { + rspamd_fprintf (stderr, + "Cannot find help for %s\n", + argv[i]); + ret = EXIT_FAILURE; + } } i++; @@ -145,7 +157,7 @@ rspamadm_confighelp (gint argc, gchar **argv) } else { /* Show all documentation strings */ - rspamadm_confighelp_show (cfg->doc_strings); + rspamadm_confighelp_show (NULL, cfg->doc_strings); } exit (ret); |