doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

Blame SOURCES/0063-cli-add-option-remove-crash-dirs-after-reporting.patch

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