Accept --help & --version as aliases to -? & -V

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-input-synaptics/-/merge_requests/25>
This commit is contained in:
Alan Coopersmith
2025-04-27 13:02:30 -07:00
parent 252ca68fef
commit 42ac30568e
2 changed files with 38 additions and 11 deletions

View File

@@ -466,14 +466,14 @@ dp_show_settings(Display * dpy, XDevice * dev)
}
static void
usage(void)
usage(int exitstatus)
{
fprintf(stderr, "Usage: synclient [-h] [-l] [-V] [-?] [var1=value1 [var2=value2] ...]\n");
fprintf(stderr, " -l List current user settings\n");
fprintf(stderr, " -V Print synclient version string and exit\n");
fprintf(stderr, " -? Show this help message\n");
fprintf(stderr, " var=value Set user parameter 'var' to 'value'.\n");
exit(1);
exit(exitstatus);
}
int
@@ -489,6 +489,17 @@ main(int argc, char *argv[])
if (argc == 1)
dump_settings = 1;
/* For now we only handle these two --options */
for (int n = 1; n < argc; n++) {
if (strcmp(argv[n], "--help") == 0) {
usage(EXIT_SUCCESS);
}
if (strcmp(argv[n], "--version") == 0) {
puts(VERSION);
exit(EXIT_SUCCESS);
}
}
/* Parse command line parameters */
while ((c = getopt(argc, argv, "lV?")) != -1) {
switch (c) {
@@ -496,17 +507,18 @@ main(int argc, char *argv[])
dump_settings = 1;
break;
case 'V':
printf("%s\n", VERSION);
exit(0);
puts(VERSION);
exit(EXIT_SUCCESS);
case '?':
usage(EXIT_SUCCESS);
default:
usage();
usage(EXIT_FAILURE);
}
}
first_cmd = optind;
if (!dump_settings && first_cmd == argc)
usage();
usage(EXIT_FAILURE);
dpy = dp_init();
if (!dpy || !(dev = dp_get_device(dpy)))

View File

@@ -76,7 +76,7 @@ static int verbose;
static unsigned char keyboard_mask[KEYMAP_SIZE];
static void
usage(void)
usage(int exitstatus)
{
fprintf(stderr,
"Usage: syndaemon [-i idle-time] [-m poll-delay] [-d [-p pid-file]] [-tkKRv] [-V]\n");
@@ -96,7 +96,7 @@ usage(void)
fprintf(stderr, " -v Print diagnostic messages.\n");
fprintf(stderr, " -V Print version string and exit\n");
fprintf(stderr, " -? Show this help message.\n");
exit(1);
exit(exitstatus);
}
static void
@@ -571,6 +571,17 @@ main(int argc, char *argv[])
int c;
int use_xrecord = 0;
/* For now we only handle these two --options */
for (int n = 1; n < argc; n++) {
if (strcmp(argv[n], "--help") == 0) {
usage(EXIT_SUCCESS);
}
if (strcmp(argv[n], "--version") == 0) {
puts(VERSION);
exit(EXIT_SUCCESS);
}
}
/* Parse command line parameters */
while ((c = getopt(argc, argv, "i:m:dtp:kKR?vV")) != EOF) {
switch (c) {
@@ -606,13 +617,17 @@ main(int argc, char *argv[])
puts(VERSION);
exit(EXIT_SUCCESS);
case '?':
usage(EXIT_SUCCESS);
default:
usage();
usage(1);
break;
}
}
if (idle_time <= 0.0)
usage();
if (idle_time <= 0.0) {
fprintf(stderr, "%s: invalid idle_time %g, cannot be <= 0.0\n\n",
argv[0], idle_time);
usage(1);
}
/* Open a connection to the X server */
display = XOpenDisplay(NULL);