From c6164002398bc9c37f1a2f2a518cf17504944783 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 8 Feb 2020 17:11:26 -0500 Subject: [PATCH] cmd: Add an option to force the command line arguments. The next commit will add modeline support. By default, modelines have the final work on which options to set. However, mostly for testing, this isn't flexible enough. --- options.c | 5 +++++ options.h | 1 + tests/run.sh | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/options.c b/options.c index a66a6c41..2272da5d 100644 --- a/options.c +++ b/options.c @@ -37,6 +37,7 @@ exit_help(int exit_code) "Usage: awesome [OPTION]\n\ -h, --help show help\n\ -v, --version show version\n\ + -f, --force ignore modelines and apply the command line arguments\n\ -c, --config FILE configuration file to use\n\ --search DIR add a directory to the library search path\n\ -k, --check check configuration file syntax\n\ @@ -58,6 +59,7 @@ options_check_args(int argc, char **argv, int *init_flags, string_array_t *paths { "help", NO_ARG, NULL, 'h' }, { "version", NO_ARG, NULL, 'v' }, { "config", ARG , NULL, 'c' }, + { "force" , NO_ARG, NULL, 'f' }, { "check", NO_ARG, NULL, 'k' }, { "search", ARG , NULL, 's' }, { "no-argb", NO_ARG, NULL, 'a' }, @@ -81,6 +83,9 @@ options_check_args(int argc, char **argv, int *init_flags, string_array_t *paths if (! ((*init_flags) & INIT_FLAG_ALLOW_FALLBACK)) exit_help(EXIT_SUCCESS); break; + case 'f': + (*init_flags) |= INIT_FLAG_FORCE_CMD_ARGS; + break; case 'k': (*init_flags) |= INIT_FLAG_RUN_TEST; break; diff --git a/options.h b/options.h index cc0dfb33..7a0d76ae 100644 --- a/options.h +++ b/options.h @@ -31,6 +31,7 @@ typedef enum { INIT_FLAG_REPLACE_WM = 0x1 << 2, INIT_FLAG_AUTO_SCREEN = 0x1 << 3, INIT_FLAG_ALLOW_FALLBACK = 0x1 << 4, + INIT_FLAG_FORCE_CMD_ARGS = 0x1 << 5, } awesome_init_config_t; char *options_check_args(int argc, char **argv, int *init_flags, string_array_t *paths); diff --git a/tests/run.sh b/tests/run.sh index 3a704656..ec4395c6 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -115,7 +115,7 @@ fi # shellcheck disable=SC2206 awesome_options=($AWESOME_OPTIONS $manual_screens --search lib --search "$this_dir") -awesome_options+=(--screen off) +awesome_options+=(--screen off --force) # Cleanup on errors / aborting. cleanup() {