aboutsummaryrefslogtreecommitdiffstats
path: root/ariketa.sh
diff options
context:
space:
mode:
authorJames Pannacciulli <jpnc@jpnc.info>2017-06-12 11:21:21 -0700
committerJames Pannacciulli <jpnc@jpnc.info>2017-06-12 11:21:21 -0700
commit1b09c0814cd1e5d5a57be0c45c879fe0b146d220 (patch)
tree08675c158599f6feff08a6c4d244b729c5e5c1bb /ariketa.sh
parent479f4a166b5d81ce6b363cce13c9763f09c74211 (diff)
downloadariketa-1b09c0814cd1e5d5a57be0c45c879fe0b146d220.tar.gz
ariketa-1b09c0814cd1e5d5a57be0c45c879fe0b146d220.tar.bz2
move sample examples out of config, show USAGE if no examples
Diffstat (limited to 'ariketa.sh')
-rw-r--r--ariketa.sh17
1 files changed, 14 insertions, 3 deletions
diff --git a/ariketa.sh b/ariketa.sh
index 658588f..38ac242 100644
--- a/ariketa.sh
+++ b/ariketa.sh
@@ -27,6 +27,20 @@ _sourced? || {
ARIKETA_DIR=$(_ariketa.dir)
+# load examples array
+source "${ARIKETA_DIR:?}/config/examples.sh"
+
+# if examples array has no content, bail with USAGE text
+(( ${#_examples[@]} )) || {
+ >&2 printf "** %s\n" \
+ "" ""\
+ "$(declare -p _examples)"\
+ "_examples array needs content -- see 'configuration' below"\
+ "" ""
+ _ariketa.help
+ return $?
+}
+
# preserve multiline commands as such in history
shopt -s lithist
@@ -39,8 +53,5 @@ source "${ARIKETA_DIR:?}/lib/functions.sh"
# set up bash macros to page through examples
source "${ARIKETA_DIR:?}/lib/bindings.sh"
-# load examples array
-source "${ARIKETA_DIR:?}/config/examples.sh"
-
# unset example index/directionality markers
unset _I _D