summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-05-25 15:42:46 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-06-02 12:21:35 +1000
commit2d42e87debc5cb659d09ee5fb315b76201a05829 (patch)
tree7ca788c9a3618899bc801562b7532e154fb12d84 /tools
parenta69294251df92e818f695cd2456c8eb860e02522 (diff)
tools: tidy up the usage() for the tools a bit
Now that the debug-gui is a user-visible tool, make sure the usage reflects the right command name. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/libinput-debug-events.c2
-rw-r--r--tools/libinput-debug-gui.c2
-rw-r--r--tools/shared.c38
-rw-r--r--tools/shared.h7
4 files changed, 28 insertions, 21 deletions
diff --git a/tools/libinput-debug-events.c b/tools/libinput-debug-events.c
index cf29dab..abba707 100644
--- a/tools/libinput-debug-events.c
+++ b/tools/libinput-debug-events.c
@@ -907,7 +907,7 @@ main(int argc, char **argv)
tools_init_context(&context);
- if (tools_parse_args(argc, argv, &context))
+ if (tools_parse_args("debug-events", argc, argv, &context))
return 1;
be_quiet = context.options.quiet;
diff --git a/tools/libinput-debug-gui.c b/tools/libinput-debug-gui.c
index fa68527..4091b55 100644
--- a/tools/libinput-debug-gui.c
+++ b/tools/libinput-debug-gui.c
@@ -877,7 +877,7 @@ main(int argc, char **argv)
tools_init_context(&context);
- if (tools_parse_args(argc, argv, &context) != 0)
+ if (tools_parse_args("debug-gui", argc, argv, &context) != 0)
return 1;
udev = udev_new();
diff --git a/tools/shared.c b/tools/shared.c
index bdbf820..fef9747 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -93,9 +93,10 @@ log_handler(struct libinput *li,
}
void
-tools_usage(void)
+tools_usage(const char *command)
{
- printf("Usage: libinput debug-events [options] [--udev [<seat>]|--device /dev/input/event0]\n");
+ printf("Usage: libinput %s [options] [--udev [<seat>]|--device /dev/input/event0]\n",
+ command);
printf("--udev <seat>.... Use udev device discovery (default).\n"
" Specifying a seat ID is optional.\n"
"--device /path/to/device .... open the given device only\n"
@@ -160,7 +161,10 @@ tools_init_context(struct tools_context *context)
}
int
-tools_parse_args(int argc, char **argv, struct tools_context *context)
+tools_parse_args(const char *command,
+ int argc,
+ char **argv,
+ struct tools_context *context)
{
struct tools_options *options = &context->options;
@@ -205,12 +209,12 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
switch(c) {
case 'h':
case OPT_HELP:
- tools_usage();
+ tools_usage(command);
exit(0);
case OPT_DEVICE:
options->backend = BACKEND_DEVICE;
if (!optarg) {
- tools_usage();
+ tools_usage(command);
return 1;
}
options->device = optarg;
@@ -234,7 +238,7 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
break;
case OPT_TAP_MAP:
if (!optarg) {
- tools_usage();
+ tools_usage(command);
return 1;
}
if (streq(optarg, "lrm")) {
@@ -242,7 +246,7 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
} else if (streq(optarg, "lmr")) {
options->tap_map = LIBINPUT_CONFIG_TAP_MAP_LMR;
} else {
- tools_usage();
+ tools_usage(command);
return 1;
}
break;
@@ -284,7 +288,7 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
break;
case OPT_CLICK_METHOD:
if (!optarg) {
- tools_usage();
+ tools_usage(command);
return 1;
}
if (streq(optarg, "none")) {
@@ -297,13 +301,13 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
options->click_method =
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
} else {
- tools_usage();
+ tools_usage(command);
return 1;
}
break;
case OPT_SCROLL_METHOD:
if (!optarg) {
- tools_usage();
+ tools_usage(command);
return 1;
}
if (streq(optarg, "none")) {
@@ -319,13 +323,13 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
options->scroll_method =
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
} else {
- tools_usage();
+ tools_usage(command);
return 1;
}
break;
case OPT_SCROLL_BUTTON:
if (!optarg) {
- tools_usage();
+ tools_usage(command);
return 1;
}
options->scroll_button =
@@ -340,14 +344,14 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
break;
case OPT_SPEED:
if (!optarg) {
- tools_usage();
+ tools_usage(command);
return 1;
}
options->speed = atof(optarg);
break;
case OPT_PROFILE:
if (!optarg) {
- tools_usage();
+ tools_usage(command);
return 1;
}
if (streq(optarg, "adaptive")) {
@@ -355,7 +359,7 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
} else if (streq(optarg, "flat")) {
options->profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
} else {
- tools_usage();
+ tools_usage(command);
return 1;
}
break;
@@ -366,14 +370,14 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
options->quiet = true;
break;
default:
- tools_usage();
+ tools_usage(command);
return 1;
}
}
if (optind < argc) {
- tools_usage();
+ tools_usage(command);
return 1;
}
diff --git a/tools/shared.h b/tools/shared.h
index f3a10db..4d6e700 100644
--- a/tools/shared.h
+++ b/tools/shared.h
@@ -65,10 +65,13 @@ struct tools_context {
};
void tools_init_context(struct tools_context *context);
-int tools_parse_args(int argc, char **argv, struct tools_context *context);
+int tools_parse_args(const char *command,
+ int argc,
+ char **argv,
+ struct tools_context *context);
struct libinput* tools_open_backend(struct tools_context *context);
void tools_device_apply_config(struct libinput_device *device,
struct tools_options *options);
-void tools_usage(void);
+void tools_usage(const char *command);
#endif