44797e
From fa289049950f8c64455e94dd07bec2170a2d28e2 Mon Sep 17 00:00:00 2001
44797e
From: Matej Habrnal <mhabrnal@redhat.com>
44797e
Date: Sat, 20 Sep 2014 11:24:25 +0200
44797e
Subject: [ABRT PATCH 63/66] cli: add option remove crash dirs after reporting
44797e
44797e
Add option -d to abrt-cli report which allows delete dump dir after the problem
44797e
was successfully reported.
44797e
44797e
Resolves #1067545
44797e
44797e
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
44797e
Signed-off-by: Jakub Filak <jfilak@redhat.com>
44797e
---
44797e
 po/POTFILES.in   |  1 +
44797e
 src/cli/report.c | 18 ++++++++++++++++--
44797e
 2 files changed, 17 insertions(+), 2 deletions(-)
44797e
44797e
diff --git a/po/POTFILES.in b/po/POTFILES.in
44797e
index e3f917b..141c73a 100644
44797e
--- a/po/POTFILES.in
44797e
+++ b/po/POTFILES.in
44797e
@@ -51,6 +51,7 @@ src/cli/abrt-cli-core.c
44797e
 src/cli/abrt-cli.c
44797e
 src/cli/list.c
44797e
 src/cli/status.c
44797e
+src/cli/report.c
44797e
 
44797e
 src/plugins/analyze_CCpp.xml.in
44797e
 src/plugins/analyze_VMcore.xml.in
44797e
diff --git a/src/cli/report.c b/src/cli/report.c
44797e
index 3321a78..33d8b44 100644
44797e
--- a/src/cli/report.c
44797e
+++ b/src/cli/report.c
44797e
@@ -26,14 +26,20 @@ int cmd_report(int argc, const char **argv)
44797e
 {
44797e
     const char *program_usage_string = _(
44797e
         "& report [options] DIR..."
44797e
-        );
44797e
+    );
44797e
+
44797e
+    enum {
44797e
+        OPT_v = 1 << 0,
44797e
+        OPT_d = 1 << 1,
44797e
+    };
44797e
 
44797e
     struct options program_options[] = {
44797e
         OPT__VERBOSE(&g_verbose),
44797e
+        OPT_BOOL('d', "delete", NULL, _("Remove PROBLEM_DIR after reporting")),
44797e
         OPT_END()
44797e
     };
44797e
 
44797e
-    parse_opts(argc, (char **)argv, program_options, program_usage_string);
44797e
+    unsigned opts = parse_opts(argc, (char **)argv, program_options, program_usage_string);
44797e
     argv += optind;
44797e
 
44797e
     if (!argv[0])
44797e
@@ -58,6 +64,14 @@ int cmd_report(int argc, const char **argv)
44797e
         int status = report_problem_in_dir(dir_name,
44797e
                                              LIBREPORT_WAIT
44797e
                                            | LIBREPORT_RUN_CLI);
44797e
+
44797e
+        /* the problem was successfully reported and option is -d */
44797e
+        if((opts & OPT_d) && (status == 0 || status == EXIT_STOP_EVENT_RUN))
44797e
+        {
44797e
+            log(_("Deleting '%s'"), dir_name);
44797e
+            delete_dump_dir_possibly_using_abrtd(dir_name);
44797e
+        }
44797e
+
44797e
         free(free_me);
44797e
 
44797e
         if (status)
44797e
-- 
44797e
1.8.3.1
44797e