- this new command prints just a count of crashes detected by abrt
---
po/POTFILES.in | 1 +
src/cli/Makefile.am | 1 +
src/cli/abrt-cli.c | 1 +
src/cli/builtin-cmd.h | 1 +
src/cli/status.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 67 insertions(+)
create mode 100644 src/cli/status.c
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9054e3f..b057a3d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -37,6 +37,7 @@ src/plugins/bodhi.c
src/cli/abrt-cli.c
src/cli/list.c
+src/cli/status.c
src/plugins/analyze_CCpp.xml.in
src/plugins/analyze_VMcore.xml.in
src/plugins/collect_GConf.xml.in
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index 5b39353..2f70ec7 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -8,6 +8,7 @@ BUILTIN_C =
BUILTIN_C += list.c
BUILTIN_C += rm.c
BUILTIN_C += report.c
+BUILTIN_C += status.c
abrt_cli_SOURCES = $(CLI_C) $(BUILTIN_C) builtin-cmd.h abrt-cli-core.h
diff --git a/src/cli/abrt-cli.c b/src/cli/abrt-cli.c
index f4b0e7e..a1ab7ec 100644
--- a/src/cli/abrt-cli.c
+++ b/src/cli/abrt-cli.c
@@ -147,6 +147,7 @@ int main(int argc, const char **argv)
CMD(rm, _("Remove problem directory DIR")),
CMD(report, _("Analyze and report problem data in DIR")),
CMD(info, _("Print information about DIR")),
+ CMD(status, _("Print the count of the recent crashes")),
{NULL, NULL, NULL}
};
diff --git a/src/cli/builtin-cmd.h b/src/cli/builtin-cmd.h
index cea77d8..491760b 100644
--- a/src/cli/builtin-cmd.h
+++ b/src/cli/builtin-cmd.h
@@ -24,5 +24,6 @@ extern int cmd_list(int argc, const char **argv);
extern int cmd_rm(int argc, const char **argv);
extern int cmd_report(int argc, const char **argv);
extern int cmd_info(int argc, const char **argv);
+extern int cmd_status(int argc, const char **argv);
#endif /* _BUILTIN-CMD_H_ */
diff --git a/src/cli/status.c b/src/cli/status.c
new file mode 100644
index 0000000..99e35df
--- /dev/null
+++ b/src/cli/status.c
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2011 ABRT Team
+ Copyright (C) 2011 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include <unistd.h>
+#include <sys/types.h>
+#include "problem_api.h"
+
+int cmd_status(int argc, const char **argv)
+{
+ const char *program_usage_string = _(
+ "& status [DIR]..."
+ );
+
+
+ bool opt_bare = false;
+ int opt_since = 0;
+
+ struct options program_options[] = {
+ OPT__VERBOSE(&g_verbose),
+ OPT_GROUP(""),
+ OPT_BOOL ('b', "bare", &opt_bare, _("Print
only the problem count without any message")),
+ OPT_INTEGER('s', "since", &opt_since, _("Print
only the problems more recent than specified timestamp")),
+ OPT_END()
+ };
+
+ parse_opts(argc, (char **)argv, program_options, program_usage_string);
+ argv += optind;
+
+ GList *problem_dir_list = NULL;
+ while (*argv)
+ problem_dir_list = g_list_append(problem_dir_list, xstrdup(*argv++));
+
+ unsigned int problem_count = get_problems_count(problem_dir_list, opt_since);
+
+ /* show only if there is at least 1 problem or user set the -v */
+ if (problem_count > 0 || g_verbose > 0)
+ {
+ if (opt_bare)
+ printf("%u", problem_count);
+ else
+ printf(_("ABRT has detected '%u' problem(s). (For more info run:
$ abrt-cli list --full)\n"), problem_count);
+ }
+
+ list_free_with_free(problem_dir_list);
+
+ return 0;
+}
\ No newline at end of file
--
1.8.1.4