main.c: add -v, -V, -d command line options

This commit is contained in:
Johan Malm 2021-03-06 11:38:17 +00:00
parent 5a36fef547
commit 5101ee87eb
2 changed files with 15 additions and 20 deletions

View file

@ -1,6 +1,7 @@
project( project(
'labwc', 'labwc',
'c', 'c',
version: '0.1.0',
license: 'GPL-2', license: 'GPL-2',
default_options: [ default_options: [
'c_std=c11', 'c_std=c11',
@ -26,6 +27,9 @@ add_project_arguments(cc.get_supported_arguments(
language: 'c', language: 'c',
) )
version='"@0@"'.format(meson.project_version())
add_project_arguments('-DLABWC_VERSION=@0@'.format(version), language: 'c')
wlroots_proj = subproject( wlroots_proj = subproject(
'wlroots', 'wlroots',
default_options: ['examples=false'], default_options: ['examples=false'],

View file

@ -10,7 +10,7 @@
struct rcxml rc = { 0 }; struct rcxml rc = { 0 };
static const char labwc_usage[] = static const char labwc_usage[] =
"Usage: labwc [-h] [-s <startup-command>] [-c <config-file>] [-v]\n"; "Usage: labwc [-h] [-s <command>] [-c <config-file>] [-d] [-V] [-v]\n";
static void static void
usage(void) usage(void)
@ -24,23 +24,25 @@ main(int argc, char *argv[])
{ {
char *startup_cmd = NULL; char *startup_cmd = NULL;
char *config_file = NULL; char *config_file = NULL;
enum verbosity { enum wlr_log_importance verbosity = WLR_ERROR;
LAB_VERBOSITY_ERROR = 0,
LAB_VERBOSITY_INFO,
LAB_VERBOSITY_DEBUG,
} verbosity = LAB_VERBOSITY_ERROR;
int c; int c;
while ((c = getopt(argc, argv, "c:s:hv")) != -1) { while ((c = getopt(argc, argv, "c:dhs:vV")) != -1) {
switch (c) { switch (c) {
case 'c': case 'c':
config_file = optarg; config_file = optarg;
break; break;
case 'd':
verbosity = WLR_DEBUG;
break;
case 's': case 's':
startup_cmd = optarg; startup_cmd = optarg;
break; break;
case 'v': case 'v':
++verbosity; printf("labwc " LABWC_VERSION "\n");
exit(0);
case 'V':
verbosity = WLR_INFO;
break; break;
case 'h': case 'h':
default: default:
@ -51,18 +53,7 @@ main(int argc, char *argv[])
usage(); usage();
} }
switch (verbosity) { wlr_log_init(verbosity, NULL);
case LAB_VERBOSITY_ERROR:
wlr_log_init(WLR_ERROR, NULL);
break;
case LAB_VERBOSITY_INFO:
wlr_log_init(WLR_INFO, NULL);
break;
case LAB_VERBOSITY_DEBUG:
default:
wlr_log_init(WLR_DEBUG, NULL);
break;
}
session_environment_init(); session_environment_init();
rcxml_read(config_file); rcxml_read(config_file);