summaryrefslogtreecommitdiff
path: root/cliutils.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-08-20 12:08:10 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-08-20 13:49:18 +0300
commitb217529967f972225dc9b7d2e37860885fde1ee1 (patch)
tree8697d585eb08ca8a692c313540f47359d24a1e27 /cliutils.c
parent04b1816f008d465ea5d7fa686e092280c3f104c3 (diff)
downloadrpm-b217529967f972225dc9b7d2e37860885fde1ee1.tar.gz
Add a convenience library for stuff common cli-bits into
Diffstat (limited to 'cliutils.c')
-rw-r--r--cliutils.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/cliutils.c b/cliutils.c
new file mode 100644
index 000000000..b1ffd2465
--- /dev/null
+++ b/cliutils.c
@@ -0,0 +1,36 @@
+#include "system.h"
+#include <rpm/rpmlog.h>
+#include <rpm/rpmlib.h>
+#include "cliutils.h"
+#include "debug.h"
+
+RPM_GNUC_NORETURN
+void argerror(const char * desc)
+{
+ fprintf(stderr, _("%s: %s\n"), __progname, desc);
+ exit(EXIT_FAILURE);
+}
+
+static void printVersion(FILE * fp)
+{
+ fprintf(fp, _("RPM version %s\n"), rpmEVR);
+}
+
+static void printBanner(FILE * fp)
+{
+ fprintf(fp, _("Copyright (C) 1998-2002 - Red Hat, Inc.\n"));
+ fprintf(fp, _("This program may be freely redistributed under the terms of the GNU GPL\n"));
+}
+
+void printUsage(poptContext con, FILE * fp, int flags)
+{
+ printVersion(fp);
+ printBanner(fp);
+ fprintf(fp, "\n");
+
+ if (rpmIsVerbose())
+ poptPrintHelp(con, fp, flags);
+ else
+ poptPrintUsage(con, fp, flags);
+}
+