Add a convenience library for stuff common cli-bits into
[platform/upstream/rpm.git] / cliutils.c
1 #include "system.h"
2 #include <rpm/rpmlog.h>
3 #include <rpm/rpmlib.h>
4 #include "cliutils.h"
5 #include "debug.h"
6
7 RPM_GNUC_NORETURN
8 void argerror(const char * desc)
9 {
10     fprintf(stderr, _("%s: %s\n"), __progname, desc);
11     exit(EXIT_FAILURE);
12 }
13
14 static void printVersion(FILE * fp)
15 {
16     fprintf(fp, _("RPM version %s\n"), rpmEVR);
17 }
18
19 static void printBanner(FILE * fp)
20 {
21     fprintf(fp, _("Copyright (C) 1998-2002 - Red Hat, Inc.\n"));
22     fprintf(fp, _("This program may be freely redistributed under the terms of the GNU GPL\n"));
23 }
24
25 void printUsage(poptContext con, FILE * fp, int flags)
26 {
27     printVersion(fp);
28     printBanner(fp);
29     fprintf(fp, "\n");
30
31     if (rpmIsVerbose())
32         poptPrintHelp(con, fp, flags);
33     else
34         poptPrintUsage(con, fp, flags);
35 }
36