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

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