diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-04 15:25:41 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-04 15:31:36 -0800 |
commit | ceb0d9909501af183e5b404b4d248356bad9ef18 (patch) | |
tree | e4c0c9dd2c530fa99d1f59f21a111f470892e52b | |
parent | 96d84072fe0d0dcbd047cc8f9b3012e0c522d125 (diff) |
Add --version option
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | doc/xrestop.1 | 7 | ||||
-rw-r--r-- | xrestop.c | 23 |
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. @@ -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) { |