aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-06-12 08:12:19 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-06-12 08:12:19 +0000
commit6a0a6b0b0199f8ef048c05600622f38cb0d92b51 (patch)
tree6d58546ee4af49d67b94e0013c6436e85ef81a70 /main.c
parentMerge branch 'no-conf-found-is-not-an-error' (diff)
parentOverride options from command line (diff)
Merge branch 'config-cli-override'
Closes #554
Diffstat (limited to 'main.c')
-rw-r--r--main.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/main.c b/main.c
index 82795424..52ebaca6 100644
--- a/main.c
+++ b/main.c
@@ -62,6 +62,7 @@ print_usage(const char *prog_name)
"Options:\n"
" -c,--config=PATH load configuration from PATH ($XDG_CONFIG_HOME/foot/foot.ini)\n"
" -C,--check-config verify configuration, exit with 0 if ok, otherwise exit with 1\n"
+ " -o,--override [section.]key=value override configuration option\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 (%s)\n"
" -T,--title=TITLE initial window title (foot)\n"
@@ -165,6 +166,7 @@ main(int argc, char *const *argv)
static const struct option longopts[] = {
{"config", required_argument, NULL, 'c'},
{"check-config", no_argument, NULL, 'C'},
+ {"override", required_argument, NULL, 'o'},
{"term", required_argument, NULL, 't'},
{"title", required_argument, NULL, 'T'},
{"app-id", required_argument, NULL, 'a'},
@@ -210,9 +212,11 @@ main(int argc, char *const *argv)
enum log_colorize log_colorize = LOG_COLORIZE_AUTO;
bool log_syslog = true;
user_notifications_t user_notifications = tll_init();
+ config_override_t overrides = tll_init();
while (true) {
- int c = getopt_long(argc, argv, "+c:Ct:T:a:LD:f:w:W:s::HmFPp:d:l::Svh", longopts, NULL);
+ int c = getopt_long(argc, argv, "+c:Co:t:T:a:LD:f:w:W:s::HmFPp:d:l::Svh", longopts, NULL);
+
if (c == -1)
break;
@@ -225,6 +229,10 @@ main(int argc, char *const *argv)
check_config = true;
break;
+ case 'o':
+ tll_push_back(overrides, optarg);
+ break;
+
case 't':
conf_term = optarg;
break;
@@ -404,7 +412,9 @@ main(int argc, char *const *argv)
}
struct config conf = {NULL};
- if (!config_load(&conf, conf_path, &user_notifications, check_config)) {
+ bool conf_successful = config_load(&conf, conf_path, &user_notifications, &overrides, check_config);
+ tll_free(overrides);
+ if (!conf_successful) {
config_free(conf);
return ret;
}