summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-04 15:25:41 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-04 15:31:36 -0800
commitceb0d9909501af183e5b404b4d248356bad9ef18 (patch)
treee4c0c9dd2c530fa99d1f59f21a111f470892e52b
parent96d84072fe0d0dcbd047cc8f9b3012e0c522d125 (diff)
Add --version option
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--doc/xrestop.17
-rw-r--r--xrestop.c23
2 files changed, 22 insertions, 8 deletions
diff --git a/doc/xrestop.1 b/doc/xrestop.1
index f9c6d77..05b14cf 100644
--- a/doc/xrestop.1
+++ b/doc/xrestop.1
@@ -13,8 +13,11 @@ as a developer tool to aid more efficient server resource usage and
debug server\-side resource leakage.
.SH OPTIONS
.TP
-\fB\-\-help\fP
-Show usage.
+\fB\-\-help\fP, \fB\-h\fP
+Show usage and exit.
+.TP
+\fB\-\-version\fP, \fB\-V\fP
+Print version and exit.
.TP
\fB\-\-display, \-d\fP <display>
Specify X11 display to monitor.
diff --git a/xrestop.c b/xrestop.c
index 58b2e44..c3e9de3 100644
--- a/xrestop.c
+++ b/xrestop.c
@@ -230,7 +230,10 @@ usage(char *progname)
" -display, -d specify X Display to monitor.\n"
" --delay-time, -t <int> specify time in seconds between sampling.\n"
" --batch, -b run in batch mode.\n"
- " --max-samples,-m <int> Maximum overall readings to take.\n\n",
+ " --max-samples,-m <int> Maximum overall readings to take.\n"
+ " --help, -h print this usage message.\n"
+ " --version, -V print version info.\n"
+ "\n",
progname);
exit(1);
@@ -684,12 +687,20 @@ main(int argc, char **argv)
continue;
}
- if (!strcmp("--help", argv[i]) || !strcmp("-h", argv[i])) {
- usage(argv[0]);
- }
+ if (!strcmp("--version", argv[i]) || !strcmp("-V", argv[i]))
+ {
+ puts(PACKAGE_STRING);
+ exit(0);
+ }
- usage(argv[0]);
- }
+ if (!strcmp("--help", argv[i]) || !strcmp("-h", argv[i]))
+ {
+ usage(argv[0]);
+ }
+
+ fprintf(stderr, "%s: Unknown argument: %s\n\n", argv[0], argv[i]);
+ usage(argv[0]);
+ }
if ((app->dpy = XOpenDisplay(app->dpy_name)) == NULL)
{