commit 2a591c590b0799f64a8492bfb24b73f05f89db3a parent 16118c46c5747488f7a9507ec5d7abbfe43013fa Author: Ayush Agarwal <ayush@fastmail.in> Date: Fri, 18 Feb 2022 22:32:50 +0530 fix: set default values after argparse and config Diffstat:
| M | tessen | | | 33 | +++++++++++++++++---------------- |
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/tessen b/tessen @@ -745,22 +745,8 @@ parse_config() { } main() { - # initialize basic options for users who expect sane defaults and don't use - # either the config file or args - if [[ -z $pass_backend ]]; then - find_pass_backend - fi - if [[ -z $dmenu_backend ]]; then - find_dmenu_backend - fi - validate_dmenu_backend "$dmenu_backend" - validate_action default - - # parse the config file - parse_config "$@" - - # parse command line arguments after the config file because args hold more - # precedence and priority than the config file + # parse arguments because they have the highest priority + # make the values supplied to -p, -d, and -a as readonly local _opt while [[ $# -gt 0 ]]; do _opt="$1" @@ -865,6 +851,21 @@ main() { readonly dmenu_backend_opts fi + # initialize basic options for users who expect sane defaults and don't use + # either the config file or args + if [[ -z $pass_backend ]]; then + find_pass_backend + readonly pass_backend + fi + if [[ -z $dmenu_backend ]]; then + find_dmenu_backend + validate_dmenu_backend "$dmenu_backend" + readonly dmenu_backend + fi + if [[ -z $tsn_action ]]; then + validate_action default + fi + trap '_clear' EXIT TERM INT if [[ $pass_backend == "pass" ]]; then get_pass_files