]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add long command line options
authorJohan Malm <jgm323@gmail.com>
Thu, 6 Oct 2022 20:54:26 +0000 (21:54 +0100)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 14 Oct 2022 22:19:18 +0000 (00:19 +0200)
docs/labwc.1.scd
src/main.c

index a8cc750dd45ff7676e8365e89d278e6ed9be3506..32ba3c610cfcdde290001cf11d0135a16f5428fa 100644 (file)
@@ -26,25 +26,25 @@ killall -s <signal> labwc
 
 # OPTIONS
 
-*-c* <config-file>
+*-c, --config* <config-file>
        Specify a config file with path
 
-*-C* <config-directory>
+*-C, --config-dir* <config-directory>
        Specify a config directory
 
-*-d*
+*-d, --debug*
        Enable full logging, including debug information
 
-*-h*
+*-h, --help*
        Show help message and quit
 
-*-s* <command>
+*-s, --startup* <command>
        Run command on startup
 
-*-v*
+*-v, --version*
        Show the version number and quit
 
-*-V*
+*-V, --verbose*
        Enable more verbose logging
 
 # SEE ALSO
index dc811f28a18954259cbc9fef5be7ed4f0e16318a..88b304d606fd527245ac7c6d7302cdb95470f5db 100644 (file)
 
 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 <config-file>    specify config file (with path)\n"
-"    -C <config-dir>     specify config directory\n"
-"    -d                  enable full logging, including debug information\n"
-"    -h                  show help message and quit\n"
-"    -s <command>        run command on startup\n"
-"    -v                  show version number and quit\n"
-"    -V                  enable more verbose logging\n";
+"  -c, --config <file>      Specify config file (with path)\n"
+"  -C, --config-dir <dir>   Specify config directory\n"
+"  -d, --debug              Enable full logging, including debug information\n"
+"  -h, --help               Show help message and quit\n"
+"  -s, --startup <command>  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;