Blob Blame History Raw
From fa289049950f8c64455e94dd07bec2170a2d28e2 Mon Sep 17 00:00:00 2001
From: Matej Habrnal <mhabrnal@redhat.com>
Date: Sat, 20 Sep 2014 11:24:25 +0200
Subject: [ABRT PATCH 63/66] cli: add option remove crash dirs after reporting

Add option -d to abrt-cli report which allows delete dump dir after the problem
was successfully reported.

Resolves #1067545

Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
 po/POTFILES.in   |  1 +
 src/cli/report.c | 18 ++++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/po/POTFILES.in b/po/POTFILES.in
index e3f917b..141c73a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -51,6 +51,7 @@ src/cli/abrt-cli-core.c
 src/cli/abrt-cli.c
 src/cli/list.c
 src/cli/status.c
+src/cli/report.c
 
 src/plugins/analyze_CCpp.xml.in
 src/plugins/analyze_VMcore.xml.in
diff --git a/src/cli/report.c b/src/cli/report.c
index 3321a78..33d8b44 100644
--- a/src/cli/report.c
+++ b/src/cli/report.c
@@ -26,14 +26,20 @@ int cmd_report(int argc, const char **argv)
 {
     const char *program_usage_string = _(
         "& report [options] DIR..."
-        );
+    );
+
+    enum {
+        OPT_v = 1 << 0,
+        OPT_d = 1 << 1,
+    };
 
     struct options program_options[] = {
         OPT__VERBOSE(&g_verbose),
+        OPT_BOOL('d', "delete", NULL, _("Remove PROBLEM_DIR after reporting")),
         OPT_END()
     };
 
-    parse_opts(argc, (char **)argv, program_options, program_usage_string);
+    unsigned opts = parse_opts(argc, (char **)argv, program_options, program_usage_string);
     argv += optind;
 
     if (!argv[0])
@@ -58,6 +64,14 @@ int cmd_report(int argc, const char **argv)
         int status = report_problem_in_dir(dir_name,
                                              LIBREPORT_WAIT
                                            | LIBREPORT_RUN_CLI);
+
+        /* the problem was successfully reported and option is -d */
+        if((opts & OPT_d) && (status == 0 || status == EXIT_STOP_EVENT_RUN))
+        {
+            log(_("Deleting '%s'"), dir_name);
+            delete_dump_dir_possibly_using_abrtd(dir_name);
+        }
+
         free(free_me);
 
         if (status)
-- 
1.8.3.1