Blob Blame Raw
From 383a8c804e0a492e8261309bbd0e9d3502ec6604 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <dvlasenk@redhat.com>
Date: Wed, 7 Dec 2011 23:14:46 +0100
Subject: [PATCH 8/8] abrt-cli: add man page. Closes rhbz#747624

This also regularizes help text a bit, and trims code
by about 150 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
---
 abrt.spec.in       |    3 +--
 doc/Makefile.am    |    1 +
 doc/abrt-cli.txt   |   31 +++++++++++++++++++++++++++++++
 src/cli/abrt-cli.c |   10 +++++-----
 src/cli/list.c     |   19 ++++++++++---------
 src/cli/report.c   |   16 +++++++---------
 src/cli/rm.c       |   10 +++++++---
 7 files changed, 62 insertions(+), 28 deletions(-)
 create mode 100644 doc/abrt-cli.txt

diff --git a/abrt.spec.in b/abrt.spec.in
index a5e78a1..7847ac0 100644
--- a/abrt.spec.in
+++ b/abrt.spec.in
@@ -497,8 +497,7 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %files cli
 %defattr(-,root,root,-)
 %{_bindir}/abrt-cli
-# provide asap
-#% {_mandir}/man1/report-cli.1.gz
+%{_mandir}/man1/abrt-cli.1.gz
 
 %files desktop
 %defattr(-,root,root,-)
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 65a8142..5025f93 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -11,6 +11,7 @@ MAN1_TXT += abrt-action-list-dsos.txt
 MAN1_TXT += abrt-retrace-client.txt
 MAN1_TXT += abrt-handle-upload.txt
 MAN1_TXT += abrt-server.txt
+MAN1_TXT += abrt-cli.txt
 MAN1_TXT += abrt-action-save-package-data.txt
 MAN1_TXT += abrt-install-ccpp-hook.txt
 
diff --git a/doc/abrt-cli.txt b/doc/abrt-cli.txt
new file mode 100644
index 0000000..9680ad6
--- /dev/null
+++ b/doc/abrt-cli.txt
@@ -0,0 +1,31 @@
+abrt-cli(1)
+===========
+
+NAME
+----
+abrt-cli - List, remove, print, analyze, report problems
+
+SYNOPSIS
+--------
+'abrt-cli' list   [-vdf] [DIR]...
+
+'abrt-cli' rm     [-v]   DIR...
+
+'abrt-cli' report [-v]   DIR...
+
+'abrt-cli' info   [-vd]  DIR...
+
+OPTIONS
+-------
+-v,--verbose::
+   Be more verbose. Can be given multiple times.
+
+-d,--detailed::
+   Show detailed report
+
+-f,--full::
+   List even reported problems
+
+AUTHORS
+-------
+* ABRT team
diff --git a/src/cli/abrt-cli.c b/src/cli/abrt-cli.c
index 2ea5276..fdd3173 100644
--- a/src/cli/abrt-cli.c
+++ b/src/cli/abrt-cli.c
@@ -138,14 +138,14 @@ int main(int argc, const char **argv)
     argc--;
 
     const char *abrt_cli_usage_string = _(
-        "Usage: abrt-cli [--version] COMMAND [ARGS]"
+        "Usage: abrt-cli [--version] COMMAND [DIR]..."
         );
 
     const struct cmd_struct commands[] = {
-        {"list", cmd_list, _("List not yet reported problems")},
-        {"rm", cmd_rm, _("Remove files from problem directory")},
-        {"report", cmd_report, _("Analyze and report problem data in problem directory")},
-        {"info", cmd_info, _("Print information about DUMP_DIR")},
+        {"list", cmd_list, _("List not yet reported problems [in DIRs]")},
+        {"rm", cmd_rm, _("Remove problem directory DIR")},
+        {"report", cmd_report, _("Analyze and report problem data in DIR")},
+        {"info", cmd_info, _("Print information about DIR")},
         {NULL, NULL, NULL}
     };
 
diff --git a/src/cli/list.c b/src/cli/list.c
index a9b700c..565a36f 100644
--- a/src/cli/list.c
+++ b/src/cli/list.c
@@ -87,7 +87,7 @@ static void print_crash_list(vector_of_problem_data_t *crash_list, int include_r
 int cmd_list(int argc, const char **argv)
 {
     const char *program_usage_string = _(
-        "& list [options] [<dump-dir>]..."
+        "& list [options] [DIR]..."
         );
 
     static int opt_full, opt_detailed;
@@ -101,11 +101,11 @@ int cmd_list(int argc, const char **argv)
     };
 
     parse_opts(argc, (char **)argv, program_options, program_usage_string);
+    argv += optind;
 
     GList *D_list = NULL;
-    if (optind < argc)
-        while (optind < argc)
-            D_list = g_list_append(D_list, xstrdup(argv[optind++]));
+    while (*argv)
+        D_list = g_list_append(D_list, xstrdup(*argv++));
     if (!D_list)
     {
         load_abrt_conf();
@@ -130,7 +130,7 @@ int cmd_list(int argc, const char **argv)
 int cmd_info(int argc, const char **argv)
 {
     const char *program_usage_string = _(
-        "& info [options] [<dump-dir>]..."
+        "& info [options] DIR..."
         );
 
     static int opt_detailed;
@@ -143,14 +143,15 @@ int cmd_info(int argc, const char **argv)
     };
 
     parse_opts(argc, (char **)argv, program_options, program_usage_string);
+    argv += optind;
 
-    if (optind == argc)
+    if (!argv[0])
         show_usage_and_die(program_usage_string, program_options);
 
     int errs = 0;
-    while (argv[optind])
+    while (*argv)
     {
-        const char *dump_dir = argv[optind++];
+        const char *dump_dir = *argv++;
         problem_data_t *problem = fill_crash_info(dump_dir);
         if (!problem)
         {
@@ -161,7 +162,7 @@ int cmd_info(int argc, const char **argv)
 
         print_crash(problem, opt_detailed);
         free_problem_data(problem);
-        if (optind - argc)
+        if (*argv)
             printf("\n");
     }
 
diff --git a/src/cli/report.c b/src/cli/report.c
index 1e6c5ce..e20bb96 100644
--- a/src/cli/report.c
+++ b/src/cli/report.c
@@ -25,7 +25,7 @@
 int cmd_report(int argc, const char **argv)
 {
     const char *program_usage_string = _(
-        "& report [options] [<dump-dir>]..."
+        "& report [options] DIR..."
         );
 
     struct options program_options[] = {
@@ -34,6 +34,10 @@ int cmd_report(int argc, const char **argv)
     };
 
     parse_opts(argc, (char **)argv, program_options, program_usage_string);
+    argv += optind;
+
+    if (!argv[0])
+        show_usage_and_die(program_usage_string, program_options);
 
     load_abrt_conf();
     char *home = getenv("HOME");
@@ -43,12 +47,9 @@ int cmd_report(int argc, const char **argv)
     D_list = g_list_append(D_list, xstrdup(g_settings_dump_location));
     free_abrt_conf_data();
 
-    if (!argv[optind])
-        show_usage_and_die(program_usage_string, program_options);
-
-    while (1)
+    while (*argv)
     {
-        const char *dir_name = argv[optind++];
+        const char *dir_name = *argv++;
 
         vector_of_problem_data_t *ci = NULL;
         if (*dir_name == '@')
@@ -73,9 +74,6 @@ int cmd_report(int argc, const char **argv)
         free_vector_of_problem_data(ci);
         if (status)
             exit(status);
-
-        if (!argv[optind])
-            break;
     }
 
     return 0;
diff --git a/src/cli/rm.c b/src/cli/rm.c
index 4a95d93..8f185a4 100644
--- a/src/cli/rm.c
+++ b/src/cli/rm.c
@@ -28,7 +28,7 @@
 int cmd_rm(int argc, const char **argv)
 {
     const char *program_usage_string = _(
-        "& rm [options] [<dump-dir>]..."
+        "& rm [options] DIR..."
         );
 
     struct options program_options[] = {
@@ -37,12 +37,16 @@ int cmd_rm(int argc, const char **argv)
     };
 
     parse_opts(argc, (char **)argv, program_options, program_usage_string);
+    argv += optind;
+
+    if (!argv[0])
+        show_usage_and_die(program_usage_string, program_options);
 
     int errs = 0;
-    while (argv[optind])
+    while (*argv)
     {
         int status;
-        const char *rm_dir = argv[optind++];
+        const char *rm_dir = *argv++;
         status = delete_dump_dir_possibly_using_abrtd(rm_dir);
         if (!status)
             log("rm '%s'", rm_dir);
-- 
1.7.7.3