aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-07-29 15:48:22 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-07-29 15:48:22 +0000
commit86e7cb04c4e8b9fae83510b6849003acc7bce70f (patch)
tree75a88ca9d484be296c829667cd7a1ec5066f5e24 /main.c
parentconfig: add scrollback section (diff)
main: add --check-config command line option
Diffstat (limited to 'main.c')
-rw-r--r--main.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/main.c b/main.c
index 590e01c0..6523907b 100644
--- a/main.c
+++ b/main.c
@@ -46,6 +46,7 @@ print_usage(const char *prog_name)
"\n"
"Options:\n"
" -c,--config=PATH load configuration from PATH (XDG_CONFIG_HOME/footrc)\n"
+ " --check-config verify configuration, exit with 0 if ok, otherwise exit with 1\n"
" -f,--font=FONT comma separated list of fonts in fontconfig format (monospace)\n"
" -t,--term=TERM value to set the environment variable TERM to (foot)\n"
" --title=TITLE initial window title (foot)\n"
@@ -142,6 +143,7 @@ main(int argc, char *const *argv)
static const struct option longopts[] = {
{"config", required_argument, NULL, 'c'},
+ {"check-config", no_argument, NULL, 'C'},
{"term", required_argument, NULL, 't'},
{"title", required_argument, NULL, 'T'},
{"app-id", required_argument, NULL, 'a'},
@@ -161,6 +163,7 @@ main(int argc, char *const *argv)
{NULL, no_argument, NULL, 0},
};
+ bool check_config = false;
const char *conf_path = NULL;
const char *conf_term = NULL;
const char *conf_title = NULL;
@@ -181,7 +184,7 @@ main(int argc, char *const *argv)
bool log_syslog = true;
while (true) {
- int c = getopt_long(argc, argv, "+c:t:a:Lf:g:s::Pp:l::Svh", longopts, NULL);
+ int c = getopt_long(argc, argv, "+c:Ct:a:Lf:g:s::Pp:l::Svh", longopts, NULL);
if (c == -1)
break;
@@ -190,6 +193,10 @@ main(int argc, char *const *argv)
conf_path = optarg;
break;
+ case 'C':
+ check_config = true;
+ break;
+
case 't':
conf_term = optarg;
break;
@@ -320,6 +327,11 @@ main(int argc, char *const *argv)
return ret;
}
+ if (check_config) {
+ config_free(conf);
+ return EXIT_SUCCESS;
+ }
+
setlocale(LC_CTYPE, "");
LOG_INFO("locale: %s", setlocale(LC_CTYPE, NULL));
if (!locale_is_utf8()) {