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

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