diff --git a/docs/labwc.1.scd b/docs/labwc.1.scd index a8cc750d..32ba3c61 100644 --- a/docs/labwc.1.scd +++ b/docs/labwc.1.scd @@ -26,25 +26,25 @@ killall -s labwc # OPTIONS -*-c* +*-c, --config* Specify a config file with path -*-C* +*-C, --config-dir* Specify a config directory -*-d* +*-d, --debug* Enable full logging, including debug information -*-h* +*-h, --help* Show help message and quit -*-s* +*-s, --startup* Run command on startup -*-v* +*-v, --version* Show the version number and quit -*-V* +*-V, --verbose* Enable more verbose logging # SEE ALSO diff --git a/src/main.c b/src/main.c index dc811f28..88b304d6 100644 --- a/src/main.c +++ b/src/main.c @@ -14,15 +14,26 @@ struct rcxml rc = { 0 }; +static const struct option long_options[] = { + {"config", required_argument, NULL, 'c'}, + {"config-dir", required_argument, NULL, 'C'}, + {"debug", no_argument, NULL, 'd'}, + {"help", no_argument, NULL, 'h'}, + {"startup", required_argument, NULL, 's'}, + {"version", no_argument, NULL, 'v'}, + {"verbose", no_argument, NULL, 'V'}, + {0, 0, 0, 0} +}; + static const char labwc_usage[] = "Usage: labwc [options...]\n" -" -c specify config file (with path)\n" -" -C specify config directory\n" -" -d enable full logging, including debug information\n" -" -h show help message and quit\n" -" -s run command on startup\n" -" -v show version number and quit\n" -" -V enable more verbose logging\n"; +" -c, --config Specify config file (with path)\n" +" -C, --config-dir Specify config directory\n" +" -d, --debug Enable full logging, including debug information\n" +" -h, --help Show help message and quit\n" +" -s, --startup Run command on startup\n" +" -v, --version Show version number and quit\n" +" -V, --verbose Enable more verbose logging\n"; static void usage(void) @@ -44,7 +55,12 @@ main(int argc, char *argv[]) enum wlr_log_importance verbosity = WLR_ERROR; int c; - while ((c = getopt(argc, argv, "c:C:dhs:vV")) != -1) { + while (1) { + int index = 0; + c = getopt_long(argc, argv, "c:C:dhs:vV", long_options, &index); + if (c == -1) { + break; + } switch (c) { case 'c': config_file = optarg;