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.
This commit is contained in:
Emmanuel Lepage Vallee 2020-02-08 17:11:26 -05:00
parent af4b4a254f
commit c616400239
3 changed files with 7 additions and 1 deletions

View File

@ -37,6 +37,7 @@ exit_help(int exit_code)
"Usage: awesome [OPTION]\n\ "Usage: awesome [OPTION]\n\
-h, --help show help\n\ -h, --help show help\n\
-v, --version show version\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\ -c, --config FILE configuration file to use\n\
--search DIR add a directory to the library search path\n\ --search DIR add a directory to the library search path\n\
-k, --check check configuration file syntax\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' }, { "help", NO_ARG, NULL, 'h' },
{ "version", NO_ARG, NULL, 'v' }, { "version", NO_ARG, NULL, 'v' },
{ "config", ARG , NULL, 'c' }, { "config", ARG , NULL, 'c' },
{ "force" , NO_ARG, NULL, 'f' },
{ "check", NO_ARG, NULL, 'k' }, { "check", NO_ARG, NULL, 'k' },
{ "search", ARG , NULL, 's' }, { "search", ARG , NULL, 's' },
{ "no-argb", NO_ARG, NULL, 'a' }, { "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)) if (! ((*init_flags) & INIT_FLAG_ALLOW_FALLBACK))
exit_help(EXIT_SUCCESS); exit_help(EXIT_SUCCESS);
break; break;
case 'f':
(*init_flags) |= INIT_FLAG_FORCE_CMD_ARGS;
break;
case 'k': case 'k':
(*init_flags) |= INIT_FLAG_RUN_TEST; (*init_flags) |= INIT_FLAG_RUN_TEST;
break; break;

View File

@ -31,6 +31,7 @@ typedef enum {
INIT_FLAG_REPLACE_WM = 0x1 << 2, INIT_FLAG_REPLACE_WM = 0x1 << 2,
INIT_FLAG_AUTO_SCREEN = 0x1 << 3, INIT_FLAG_AUTO_SCREEN = 0x1 << 3,
INIT_FLAG_ALLOW_FALLBACK = 0x1 << 4, INIT_FLAG_ALLOW_FALLBACK = 0x1 << 4,
INIT_FLAG_FORCE_CMD_ARGS = 0x1 << 5,
} awesome_init_config_t; } awesome_init_config_t;
char *options_check_args(int argc, char **argv, int *init_flags, string_array_t *paths); char *options_check_args(int argc, char **argv, int *init_flags, string_array_t *paths);

View File

@ -115,7 +115,7 @@ fi
# shellcheck disable=SC2206 # shellcheck disable=SC2206
awesome_options=($AWESOME_OPTIONS $manual_screens --search lib --search "$this_dir") 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 on errors / aborting.
cleanup() { cleanup() {