mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-24 21:05:40 +02:00
main: add -c,--check-config
When this option is used, we exit after loading the configuration. Either with an error message and a non-zero exit code (bad config), or no messages and a zero exit code (good config).
This commit is contained in:
parent
cb0bc20b38
commit
55c5cfab46
2 changed files with 21 additions and 2 deletions
|
@ -8,6 +8,11 @@ f00bar - modular status panel for X11 and Wayland
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
|
|
||||||
|
*-c, --check-config*
|
||||||
|
Verify the configuration and then quit. If no errors are detected,
|
||||||
|
nothing is printed and the exit code is 0. If there are errors,
|
||||||
|
these are printed on stdout and the exit code is non-zero.
|
||||||
|
|
||||||
*-v, --version*
|
*-v, --version*
|
||||||
Show the version number and quit
|
Show the version number and quit
|
||||||
|
|
||||||
|
|
18
main.c
18
main.c
|
@ -124,7 +124,8 @@ print_usage(const char *prog_name)
|
||||||
printf("Usage: %s [OPTION]...\n", prog_name);
|
printf("Usage: %s [OPTION]...\n", prog_name);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Options:\n");
|
printf("Options:\n");
|
||||||
printf(" -v,--version print f00sel version and quit\n");
|
printf(" -c,--check-config verify configuration then quit\n"
|
||||||
|
" -v,--version print f00sel version and quit\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -133,17 +134,24 @@ main(int argc, char *const *argv)
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
|
||||||
static const struct option longopts[] = {
|
static const struct option longopts[] = {
|
||||||
|
{"check-config", no_argument, 0, 'c'},
|
||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, 0, 'v'},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, 0, 'h'},
|
||||||
{NULL, no_argument, 0, 0},
|
{NULL, no_argument, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool verify_config = false;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int c = getopt_long(argc, argv, ":vh", longopts, NULL);
|
int c = getopt_long(argc, argv, ":cvh", longopts, NULL);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'c':
|
||||||
|
verify_config = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
printf("f00bar version %s\n", F00BAR_VERSION);
|
printf("f00bar version %s\n", F00BAR_VERSION);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
@ -194,6 +202,12 @@ main(int argc, char *const *argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verify_config) {
|
||||||
|
bar->destroy(bar);
|
||||||
|
close(abort_fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bar->abort_fd = abort_fd;
|
bar->abort_fd = abort_fd;
|
||||||
|
|
||||||
thrd_t bar_thread;
|
thrd_t bar_thread;
|
||||||
|
|
Loading…
Add table
Reference in a new issue