Blame SOURCES/0056-cli-make-consistent-commands-in-abrt-cli.patch

baab13
From fbcbd0e922e2c7efe62a584fbd76b36fbe0e2952 Mon Sep 17 00:00:00 2001
baab13
From: Matej Habrnal <mhabrnal@redhat.com>
baab13
Date: Mon, 8 Sep 2014 13:27:56 +0200
baab13
Subject: [ABRT PATCH 56/66] cli: make consistent commands in abrt-cli
baab13
baab13
Add abbreviations to the client's parametres.
baab13
baab13
Related to rhbz#1066501
baab13
baab13
Conflicts:
baab13
	src/cli/abrt-cli.c
baab13
---
baab13
 doc/abrt-cli.txt      |  2 +-
baab13
 src/cli/abrt-cli.c    | 20 +++++++++++---------
baab13
 src/cli/builtin-cmd.h |  2 +-
baab13
 src/cli/rm.c          |  2 +-
baab13
 4 files changed, 14 insertions(+), 12 deletions(-)
baab13
baab13
diff --git a/doc/abrt-cli.txt b/doc/abrt-cli.txt
baab13
index 792e781..1c95655 100644
baab13
--- a/doc/abrt-cli.txt
baab13
+++ b/doc/abrt-cli.txt
baab13
@@ -9,7 +9,7 @@ SYNOPSIS
baab13
 --------
baab13
 'abrt-cli' list   [-vdf] [DIR]...
baab13
 
baab13
-'abrt-cli' rm     [-v]   DIR...
baab13
+'abrt-cli' remove [-v]   DIR...
baab13
 
baab13
 'abrt-cli' report [-v]   DIR...
baab13
 
baab13
diff --git a/src/cli/abrt-cli.c b/src/cli/abrt-cli.c
baab13
index a1ab7ec..c04c132 100644
baab13
--- a/src/cli/abrt-cli.c
baab13
+++ b/src/cli/abrt-cli.c
baab13
@@ -20,14 +20,15 @@
baab13
 #include "libabrt.h"
baab13
 #include "builtin-cmd.h"
baab13
 
baab13
-#define USAGE_OPTS_WIDTH 12
baab13
+#define USAGE_OPTS_WIDTH 16
baab13
 #define USAGE_GAP         2
baab13
 
baab13
 /* TODO: add --pager(default) and --no-pager */
baab13
 
baab13
-#define CMD(NAME, help) { #NAME, cmd_##NAME , (help) }
baab13
+#define CMD(NAME, ABBREV, help) { #NAME, ABBREV, cmd_##NAME , (help) }
baab13
 struct cmd_struct {
baab13
     const char *cmd;
baab13
+    const char *abbrev;
baab13
     int (*fn)(int, const char **);
baab13
     const char *help;
baab13
 };
baab13
@@ -41,6 +42,7 @@ static void list_cmds_help(const struct cmd_struct *commands)
baab13
 
baab13
         pos = fprintf(stderr, "    ");
baab13
         pos += fprintf(stderr, "%s", p->cmd);
baab13
+        pos += fprintf(stderr, ", %s", p->abbrev);
baab13
 
baab13
         if (pos <= USAGE_OPTS_WIDTH)
baab13
             pad = USAGE_OPTS_WIDTH - pos;
baab13
@@ -110,7 +112,7 @@ static void handle_internal_command(int argc, const char **argv,
baab13
 
baab13
     for (const struct cmd_struct *p = commands; p->cmd; ++p)
baab13
     {
baab13
-        if (strcmp(p->cmd, cmd) != 0)
baab13
+        if (strcmp(p->cmd, cmd) != 0 && strcmp(p->abbrev, cmd) != 0)
baab13
             continue;
baab13
 
baab13
         exit(p->fn(argc, argv));
baab13
@@ -143,12 +145,12 @@ int main(int argc, const char **argv)
baab13
         );
baab13
 
baab13
     const struct cmd_struct commands[] = {
baab13
-        CMD(list, _("List not yet reported problems [in DIRs]")),
baab13
-        CMD(rm, _("Remove problem directory DIR")),
baab13
-        CMD(report, _("Analyze and report problem data in DIR")),
baab13
-        CMD(info, _("Print information about DIR")),
baab13
-        CMD(status, _("Print the count of the recent crashes")),
baab13
-        {NULL, NULL, NULL}
baab13
+        CMD(list, "ls", _("List problems [in DIRs]")),
baab13
+        CMD(remove, "rm", _("Remove problem directory DIR")),
baab13
+        CMD(report, "e",_("Analyze and report problem data in DIR")),
baab13
+        CMD(info, "i", _("Print information about DIR")),
baab13
+        CMD(status, "st",_("Print the count of the recent crashes")),
baab13
+        {NULL, NULL, NULL, NULL}
baab13
     };
baab13
 
baab13
     migrate_to_xdg_dirs();
baab13
diff --git a/src/cli/builtin-cmd.h b/src/cli/builtin-cmd.h
baab13
index 491760b..18588e1 100644
baab13
--- a/src/cli/builtin-cmd.h
baab13
+++ b/src/cli/builtin-cmd.h
baab13
@@ -21,7 +21,7 @@
baab13
 #define _BUILTIN_CMD_H_
baab13
 
baab13
 extern int cmd_list(int argc, const char **argv);
baab13
-extern int cmd_rm(int argc, const char **argv);
baab13
+extern int cmd_remove(int argc, const char **argv);
baab13
 extern int cmd_report(int argc, const char **argv);
baab13
 extern int cmd_info(int argc, const char **argv);
baab13
 extern int cmd_status(int argc, const char **argv);
baab13
diff --git a/src/cli/rm.c b/src/cli/rm.c
baab13
index 8f185a4..fe458ff 100644
baab13
--- a/src/cli/rm.c
baab13
+++ b/src/cli/rm.c
baab13
@@ -25,7 +25,7 @@
baab13
  *   add -q, --quite
baab13
  */
baab13
 
baab13
-int cmd_rm(int argc, const char **argv)
baab13
+int cmd_remove(int argc, const char **argv)
baab13
 {
baab13
     const char *program_usage_string = _(
baab13
         "& rm [options] DIR..."
baab13
-- 
baab13
1.8.3.1
baab13