diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-29 17:37:04 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-29 17:37:04 +0000 |
commit | 6c9457f6d281b67d25443e430ad4a4512f43e98b (patch) | |
tree | cf0161cf41ee8a7e8f9f6e26e11b618c9262b408 /src/rspamadm/confighelp.c | |
parent | e6e614c520135a4c14ff25b0cd90fb53528216d6 (diff) | |
download | rspamd-6c9457f6d281b67d25443e430ad4a4512f43e98b.tar.gz rspamd-6c9457f6d281b67d25443e430ad4a4512f43e98b.zip |
Fix arguments passing to the lua formatter
Diffstat (limited to 'src/rspamadm/confighelp.c')
-rw-r--r-- | src/rspamadm/confighelp.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/rspamadm/confighelp.c b/src/rspamadm/confighelp.c index c76f580e7..3b90a4700 100644 --- a/src/rspamadm/confighelp.c +++ b/src/rspamadm/confighelp.c @@ -72,6 +72,9 @@ rspamadm_confighelp_help (gboolean full_help) "-c: output compacted JSON\n" "-j: output pretty formatted JSON\n" "-k: search by keyword in doc string\n" + "--color: show colored output\n" + "--short: show only option names\n" + "--no-examples: do not show examples (impied by --short)\n" "--help: shows available options and commands"; } else { @@ -194,13 +197,14 @@ rspamadm_confighelp (gint argc, gchar **argv) { struct rspamd_rcl_section *top; struct rspamd_config *cfg; - const ucl_object_t *doc_obj; + ucl_object_t *doc_obj; + const ucl_object_t *elt; GOptionContext *context; GError *error = NULL; module_t *mod, **pmod; worker_t **pworker; struct module_ctx *mod_ctx; - gint i = 1, ret = 0; + gint i = 1, ret = 0, processed_args = 0; context = g_option_context_new ( "confighelp - displays help for the configuration options"); @@ -249,7 +253,7 @@ rspamadm_confighelp (gint argc, gchar **argv) } if (argc > 1) { - while (argc > 1) { + for (i = 1; i < argc; i ++) { if (argv[i][0] != '-') { if (keyword) { @@ -257,15 +261,18 @@ rspamadm_confighelp (gint argc, gchar **argv) argv[i]); } else { - doc_obj = ucl_lookup_path (cfg->doc_strings, argv[i]); + doc_obj = ucl_object_typed_new (UCL_OBJECT); + elt = ucl_lookup_path (cfg->doc_strings, argv[i]); + + if (elt) { + ucl_object_insert_key (doc_obj, ucl_object_ref (elt), + argv[i], 0, false); + } } if (doc_obj != NULL) { rspamadm_confighelp_show (cfg, argc, argv, argv[i], doc_obj); - - if (keyword) { - ucl_object_unref ((ucl_object_t *)doc_obj); - } + ucl_object_unref (doc_obj); } else { rspamd_fprintf (stderr, @@ -273,13 +280,12 @@ rspamadm_confighelp (gint argc, gchar **argv) argv[i]); ret = EXIT_FAILURE; } + processed_args ++; } - - i++; - argc--; } } - else { + + if (processed_args == 0) { /* Show all documentation strings */ rspamadm_confighelp_show (cfg, argc, argv, NULL, cfg->doc_strings); } |