mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-11 05:33:55 -04:00
main: add --check-config command line option
This commit is contained in:
parent
d11d374252
commit
86e7cb04c4
4 changed files with 19 additions and 1 deletions
|
|
@ -21,6 +21,7 @@
|
||||||
**scrollback-indicator-format** options in `footrc`
|
**scrollback-indicator-format** options in `footrc`
|
||||||
(https://codeberg.org/dnkl/foot/issues/42).
|
(https://codeberg.org/dnkl/foot/issues/42).
|
||||||
* Key bindings in _scollback search_ mode are now configurable.
|
* Key bindings in _scollback search_ mode are now configurable.
|
||||||
|
* `--check-config` command line option.
|
||||||
|
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
_arguments \
|
_arguments \
|
||||||
-s -S -C \
|
-s -S -C \
|
||||||
'(-c --config)'{-c,--config}'[path to configuration file (XDG_CONFIG_HOME/footrc)]:config:_files' \
|
'(-c --config)'{-c,--config}'[path to configuration file (XDG_CONFIG_HOME/footrc)]:config:_files' \
|
||||||
|
'--check-config[verify configuration and exit with 0 if ok, otherwise exit with 1]' \
|
||||||
'(-f --font)'{-f,--font}'[font name and style in fontconfig format (monospace)]:font:->fonts' \
|
'(-f --font)'{-f,--font}'[font name and style in fontconfig format (monospace)]:font:->fonts' \
|
||||||
'(-t --term)'{-t,--term}'[value to set the environment variable TERM to (foot)]:term:->terms' \
|
'(-t --term)'{-t,--term}'[value to set the environment variable TERM to (foot)]:term:->terms' \
|
||||||
'--title[initial window title]:()' \
|
'--title[initial window title]:()' \
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,10 @@ arguments, to execute (instead of the default shell).
|
||||||
*-c*,*--config*=_PATH_
|
*-c*,*--config*=_PATH_
|
||||||
Path to configuration file. Default: *XDG_CONFIG_HOME/footrc*.
|
Path to configuration file. Default: *XDG_CONFIG_HOME/footrc*.
|
||||||
|
|
||||||
|
*--check-config*
|
||||||
|
Verify configuration and then exit with 0 if ok, otherwise exit
|
||||||
|
with 1.
|
||||||
|
|
||||||
*-f*,*--font*=_FONT_
|
*-f*,*--font*=_FONT_
|
||||||
Comma separated list of fonts to use, in fontconfig format (see
|
Comma separated list of fonts to use, in fontconfig format (see
|
||||||
*FONT FORMAT*).
|
*FONT FORMAT*).
|
||||||
|
|
|
||||||
14
main.c
14
main.c
|
|
@ -46,6 +46,7 @@ print_usage(const char *prog_name)
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -c,--config=PATH load configuration from PATH (XDG_CONFIG_HOME/footrc)\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"
|
" -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"
|
" -t,--term=TERM value to set the environment variable TERM to (foot)\n"
|
||||||
" --title=TITLE initial window title (foot)\n"
|
" --title=TITLE initial window title (foot)\n"
|
||||||
|
|
@ -142,6 +143,7 @@ main(int argc, char *const *argv)
|
||||||
|
|
||||||
static const struct option longopts[] = {
|
static const struct option longopts[] = {
|
||||||
{"config", required_argument, NULL, 'c'},
|
{"config", required_argument, NULL, 'c'},
|
||||||
|
{"check-config", no_argument, NULL, 'C'},
|
||||||
{"term", required_argument, NULL, 't'},
|
{"term", required_argument, NULL, 't'},
|
||||||
{"title", required_argument, NULL, 'T'},
|
{"title", required_argument, NULL, 'T'},
|
||||||
{"app-id", required_argument, NULL, 'a'},
|
{"app-id", required_argument, NULL, 'a'},
|
||||||
|
|
@ -161,6 +163,7 @@ main(int argc, char *const *argv)
|
||||||
{NULL, no_argument, NULL, 0},
|
{NULL, no_argument, NULL, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool check_config = false;
|
||||||
const char *conf_path = NULL;
|
const char *conf_path = NULL;
|
||||||
const char *conf_term = NULL;
|
const char *conf_term = NULL;
|
||||||
const char *conf_title = NULL;
|
const char *conf_title = NULL;
|
||||||
|
|
@ -181,7 +184,7 @@ main(int argc, char *const *argv)
|
||||||
bool log_syslog = true;
|
bool log_syslog = true;
|
||||||
|
|
||||||
while (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)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -190,6 +193,10 @@ main(int argc, char *const *argv)
|
||||||
conf_path = optarg;
|
conf_path = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'C':
|
||||||
|
check_config = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
conf_term = optarg;
|
conf_term = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
@ -320,6 +327,11 @@ main(int argc, char *const *argv)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (check_config) {
|
||||||
|
config_free(conf);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
LOG_INFO("locale: %s", setlocale(LC_CTYPE, NULL));
|
LOG_INFO("locale: %s", setlocale(LC_CTYPE, NULL));
|
||||||
if (!locale_is_utf8()) {
|
if (!locale_is_utf8()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue