dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0067-sss_override-document-debug-options.patch

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