From 33b86b5b03a29264812790aaff0e492c36a9fbe5 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 27 Oct 2015 12:46:20 -0400 Subject: Validate UI option --- (limited to 'src') diff --git a/src/main.sh b/src/main.sh index c62262e..4c9f849 100644 --- a/src/main.sh +++ b/src/main.sh @@ -72,6 +72,8 @@ main() exit 1 fi - init_ui "${ui}" + if ! init_ui "${ui}"; then + exit 1 + fi info 'Hello, world!' } diff --git a/src/ui.sh b/src/ui.sh index f6e225c..ea4071e 100644 --- a/src/ui.sh +++ b/src/ui.sh @@ -22,6 +22,15 @@ init_ui() local ui="${1}" local fn= + case "${ui}" in + 'cli' | 'tui') + ;; + *) + printf 'Error: Invalid UI "%s"\n' "${ui}" >&2 + return 1 + ;; + esac + for fn in ${ui_functions}; do eval "${fn}() { ${ui}_${fn} \"\${@}\"; }" done -- cgit v0.9.1