mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-05 18:08:09 +02:00
tools: make the tools exit with exit code 2 on usage issues
This makes it easier to test for usage issues Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
bd52bf5421
commit
36af7d312b
6 changed files with 17 additions and 15 deletions
|
|
@ -944,11 +944,11 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case '?':
|
case '?':
|
||||||
exit(1);
|
exit(EXIT_INVALID_USAGE);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage();
|
usage();
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case OPT_SHOW_KEYCODES:
|
case OPT_SHOW_KEYCODES:
|
||||||
show_keycodes = true;
|
show_keycodes = true;
|
||||||
|
|
@ -973,7 +973,7 @@ main(int argc, char **argv)
|
||||||
default:
|
default:
|
||||||
if (tools_parse_option(c, optarg, &options) != 0) {
|
if (tools_parse_option(c, optarg, &options) != 0) {
|
||||||
usage();
|
usage();
|
||||||
return 1;
|
return EXIT_INVALID_USAGE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -982,7 +982,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
usage();
|
usage();
|
||||||
return 1;
|
return EXIT_INVALID_USAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&act, 0, sizeof(act));
|
memset(&act, 0, sizeof(act));
|
||||||
|
|
@ -997,11 +997,11 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
li = tools_open_backend(backend, seat_or_device, verbose, &grab);
|
li = tools_open_backend(backend, seat_or_device, verbose, &grab);
|
||||||
if (!li)
|
if (!li)
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
mainloop(li);
|
mainloop(li);
|
||||||
|
|
||||||
libinput_unref(li);
|
libinput_unref(li);
|
||||||
|
|
||||||
return 0;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -968,7 +968,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case '?':
|
case '?':
|
||||||
exit(1);
|
exit(EXIT_INVALID_USAGE);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage();
|
usage();
|
||||||
|
|
@ -991,7 +991,7 @@ main(int argc, char **argv)
|
||||||
default:
|
default:
|
||||||
if (tools_parse_option(c, optarg, &options) != 0) {
|
if (tools_parse_option(c, optarg, &options) != 0) {
|
||||||
usage();
|
usage();
|
||||||
return 1;
|
return EXIT_INVALID_USAGE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1000,12 +1000,12 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
usage();
|
usage();
|
||||||
return 1;
|
return EXIT_INVALID_USAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
li = tools_open_backend(backend, seat_or_device, verbose, &w.grab);
|
li = tools_open_backend(backend, seat_or_device, verbose, &w.grab);
|
||||||
if (!li)
|
if (!li)
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
libinput_set_user_data(li, &w);
|
libinput_set_user_data(li, &w);
|
||||||
|
|
||||||
|
|
@ -1019,5 +1019,5 @@ main(int argc, char **argv)
|
||||||
window_cleanup(&w);
|
window_cleanup(&w);
|
||||||
libinput_unref(li);
|
libinput_unref(li);
|
||||||
|
|
||||||
return 0;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -388,7 +388,7 @@ main(int argc, char **argv)
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
usage();
|
usage();
|
||||||
return 1;
|
return EXIT_INVALID_USAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,13 +98,13 @@ main(int argc, char **argv)
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
return EXIT_FAILURE;
|
return EXIT_INVALID_USAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind >= argc) {
|
if (optind >= argc) {
|
||||||
usage();
|
usage();
|
||||||
return EXIT_FAILURE;
|
return EXIT_INVALID_USAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
|
||||||
|
|
@ -576,7 +576,7 @@ tools_exec_command(const char *prefix, int real_argc, char **real_argv)
|
||||||
"libinput: %s is not a libinput command or not installed. "
|
"libinput: %s is not a libinput command or not installed. "
|
||||||
"See 'libinput --help'\n",
|
"See 'libinput --help'\n",
|
||||||
command);
|
command);
|
||||||
|
return EXIT_INVALID_USAGE;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Failed to execute '%s' (%s)\n",
|
"Failed to execute '%s' (%s)\n",
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
#include <quirks.h>
|
#include <quirks.h>
|
||||||
#include <libinput.h>
|
#include <libinput.h>
|
||||||
|
|
||||||
|
#define EXIT_INVALID_USAGE 2
|
||||||
|
|
||||||
enum configuration_options {
|
enum configuration_options {
|
||||||
OPT_TAP_ENABLE = 256,
|
OPT_TAP_ENABLE = 256,
|
||||||
OPT_TAP_DISABLE,
|
OPT_TAP_DISABLE,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue