tools/demo-client: hook up --verbose

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2020-08-25 09:01:50 +10:00
parent c4f1a9107e
commit 55d92c8f61

View file

@ -112,7 +112,7 @@ static void
usage(FILE *fp, const char *argv0)
{
fprintf(fp,
"Usage: %s [--socket]\n"
"Usage: %s [--verbose] [--socket]\n"
"\n"
"Start an EI demo client. The client will connect to EIS\n"
"with the chosen backend (default: socket) and emulate pointer\n"
@ -121,6 +121,7 @@ usage(FILE *fp, const char *argv0)
"Options:\n"
" --socket Use the socket backend. The socket path is $LIBEI_SOCKET if set, \n"
" otherwise XDG_RUNTIME/eis-0\n",
" --verbose Enable debugging output\n",
argv0);
}
@ -129,6 +130,7 @@ int main(int argc, char **argv)
enum {
SOCKET,
} backend = SOCKET;
bool verbose = false;
while (1) {
enum {
@ -137,6 +139,7 @@ int main(int argc, char **argv)
};
static struct option long_opts[] = {
{"socket", no_argument, 0, OPT_BACKEND_SOCKET},
{"verbose", no_argument, 0, OPT_VERBOSE},
{"help", no_argument, 0, 'h'},
{NULL},
};
@ -150,6 +153,9 @@ int main(int argc, char **argv)
case 'h':
usage(stdout, argv[0]);
return EXIT_SUCCESS;
case OPT_VERBOSE:
verbose = true;
break;
case OPT_BACKEND_SOCKET:
backend = SOCKET;
break;
@ -162,7 +168,8 @@ int main(int argc, char **argv)
_cleanup_(ei_unrefp) struct ei *ei = ei_new(NULL);
assert(ei);
ei_log_set_priority(ei, EI_LOG_PRIORITY_DEBUG);
if (verbose)
ei_log_set_priority(ei, EI_LOG_PRIORITY_DEBUG);
ei_configure_name(ei, "ei-demo-client");