From c8fcc0597ad6399fe42111512d5dc2ff1362f3c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Tue, 25 Aug 2015 12:58:45 +0200
Subject: [PATCH 67/68] sss_override: document --debug options
Resolves:
https://fedorahosted.org/sssd/ticket/2758
Reviewed-by: Petr Cech <pcech@redhat.com>
---
src/man/sss_override.8.xml | 16 ++++++++++++++++
src/tools/common/sss_tools.c | 25 +++++++++++++++++++++----
2 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/src/man/sss_override.8.xml b/src/man/sss_override.8.xml
index d289f5b7dfa7fbd328831b4c71d45b4c555225cf..c2ec5dd41703c7272acf7c9d2c30f20351099791 100644
--- a/src/man/sss_override.8.xml
+++ b/src/man/sss_override.8.xml
@@ -190,6 +190,22 @@
</variablelist>
</refsect1>
+ <refsect1 id='options'>
+ <title>COMMON OPTIONS</title>
+ <para>
+ Those options are available with all commands.
+ </para>
+ <variablelist remap='IP'>
+ <varlistentry>
+ <term>
+ <option>-d</option>,<option>--debug</option>
+ <replaceable>LEVEL</replaceable>
+ </term>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="include/debug_levels.xml" />
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="include/seealso.xml" />
</refentry>
diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c
index 6bbce3a25ddddc0b23ebc108a917a38e94981b65..d50e9af7d348e984687108895f0fd3448ee9add0 100644
--- a/src/tools/common/sss_tools.c
+++ b/src/tools/common/sss_tools.c
@@ -36,6 +36,13 @@ struct sss_cmdline {
const char **argv;
};
+static void sss_tool_print_common_opts(void)
+{
+ fprintf(stderr, _("Common options:\n"));
+ fprintf(stderr, " --debug=INT %s\n",
+ _("Enable debug at level"));
+}
+
static void sss_tool_common_opts(struct sss_tool_ctx *tool_ctx,
int *argc, const char **argv)
{
@@ -201,6 +208,9 @@ int sss_tool_usage(const char *tool_name,
fprintf(stderr, "* %s\n", commands[i].command);
}
+ fprintf(stderr, _("\n"));
+ sss_tool_print_common_opts();
+
return EXIT_FAILURE;
}
@@ -237,6 +247,13 @@ int sss_tool_route(int argc, const char **argv,
return sss_tool_usage(argv[0], commands);
}
+static void sss_tool_popt_print_help(poptContext pc)
+{
+ poptPrintHelp(pc, stderr, 0);
+ fprintf(stderr, "\n");
+ sss_tool_print_common_opts();
+}
+
int sss_tool_popt_ex(struct sss_cmdline *cmdline,
struct poptOption *options,
enum sss_tool_opt require_option,
@@ -286,7 +303,7 @@ int sss_tool_popt_ex(struct sss_cmdline *cmdline,
} else {
fprintf(stderr, _("Invalid option %s: %s\n\n"),
poptBadOption(pc, 0), poptStrerror(ret));
- poptPrintHelp(pc, stderr, 0);
+ sss_tool_popt_print_help(pc);
ret = EXIT_FAILURE;
goto done;
}
@@ -297,7 +314,7 @@ int sss_tool_popt_ex(struct sss_cmdline *cmdline,
*_fopt = poptGetArg(pc);
if (*_fopt == NULL) {
fprintf(stderr, _("Missing option: %s\n\n"), fopt_help);
- poptPrintHelp(pc, stderr, 0);
+ sss_tool_popt_print_help(pc);
ret = EXIT_FAILURE;
goto done;
}
@@ -305,7 +322,7 @@ int sss_tool_popt_ex(struct sss_cmdline *cmdline,
/* No more arguments expected. If something follows it is an error. */
if (poptGetArg(pc)) {
fprintf(stderr, _("Only one free argument is expected!\n\n"));
- poptPrintHelp(pc, stderr, 0);
+ sss_tool_popt_print_help(pc);
ret = EXIT_FAILURE;
goto done;
}
@@ -315,7 +332,7 @@ int sss_tool_popt_ex(struct sss_cmdline *cmdline,
if (require_option == SSS_TOOL_OPT_REQUIRED
&& ((_fopt != NULL && cmdline->argc < 2) || cmdline->argc < 1)) {
fprintf(stderr, _("At least one option is required!\n\n"));
- poptPrintHelp(pc, stderr, 0);
+ sss_tool_popt_print_help(pc);
ret = EXIT_FAILURE;
goto done;
}
--
2.4.3