summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2015-10-27 12:46:20 (EDT)
committer P. J. McDermott <pj@pehjota.net>2015-10-27 12:46:36 (EDT)
commit33b86b5b03a29264812790aaff0e492c36a9fbe5 (patch)
tree36a43b1cda714a22d5e1da35e1931eb20e943e36
parent9635a87d9476f0a8e4a3050399724698bb831c02 (diff)
downloadfirman.sh-33b86b5b03a29264812790aaff0e492c36a9fbe5.zip
firman.sh-33b86b5b03a29264812790aaff0e492c36a9fbe5.tar.gz
firman.sh-33b86b5b03a29264812790aaff0e492c36a9fbe5.tar.bz2
Validate UI option
-rw-r--r--src/main.sh4
-rw-r--r--src/ui.sh9
2 files changed, 12 insertions, 1 deletions
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