doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

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

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