mirror of
https://github.com/labwc/labwc.git
synced 2026-03-26 07:58:08 -04:00
Add long command line options
This commit is contained in:
parent
ee00a897a4
commit
8c139e4185
2 changed files with 31 additions and 15 deletions
|
|
@ -26,25 +26,25 @@ killall -s <signal> labwc
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
|
|
||||||
*-c* <config-file>
|
*-c, --config* <config-file>
|
||||||
Specify a config file with path
|
Specify a config file with path
|
||||||
|
|
||||||
*-C* <config-directory>
|
*-C, --config-dir* <config-directory>
|
||||||
Specify a config directory
|
Specify a config directory
|
||||||
|
|
||||||
*-d*
|
*-d, --debug*
|
||||||
Enable full logging, including debug information
|
Enable full logging, including debug information
|
||||||
|
|
||||||
*-h*
|
*-h, --help*
|
||||||
Show help message and quit
|
Show help message and quit
|
||||||
|
|
||||||
*-s* <command>
|
*-s, --startup* <command>
|
||||||
Run command on startup
|
Run command on startup
|
||||||
|
|
||||||
*-v*
|
*-v, --version*
|
||||||
Show the version number and quit
|
Show the version number and quit
|
||||||
|
|
||||||
*-V*
|
*-V, --verbose*
|
||||||
Enable more verbose logging
|
Enable more verbose logging
|
||||||
|
|
||||||
# SEE ALSO
|
# SEE ALSO
|
||||||
|
|
|
||||||
32
src/main.c
32
src/main.c
|
|
@ -14,15 +14,26 @@
|
||||||
|
|
||||||
struct rcxml rc = { 0 };
|
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[] =
|
static const char labwc_usage[] =
|
||||||
"Usage: labwc [options...]\n"
|
"Usage: labwc [options...]\n"
|
||||||
" -c <config-file> specify config file (with path)\n"
|
" -c, --config <file> Specify config file (with path)\n"
|
||||||
" -C <config-dir> specify config directory\n"
|
" -C, --config-dir <dir> Specify config directory\n"
|
||||||
" -d enable full logging, including debug information\n"
|
" -d, --debug Enable full logging, including debug information\n"
|
||||||
" -h show help message and quit\n"
|
" -h, --help Show help message and quit\n"
|
||||||
" -s <command> run command on startup\n"
|
" -s, --startup <command> Run command on startup\n"
|
||||||
" -v show version number and quit\n"
|
" -v, --version Show version number and quit\n"
|
||||||
" -V enable more verbose logging\n";
|
" -V, --verbose Enable more verbose logging\n";
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
|
|
@ -44,7 +55,12 @@ main(int argc, char *argv[])
|
||||||
enum wlr_log_importance verbosity = WLR_ERROR;
|
enum wlr_log_importance verbosity = WLR_ERROR;
|
||||||
|
|
||||||
int c;
|
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) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
config_file = optarg;
|
config_file = optarg;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue