From 1b09c0814cd1e5d5a57be0c45c879fe0b146d220 Mon Sep 17 00:00:00 2001 From: James Pannacciulli Date: Mon, 12 Jun 2017 11:21:21 -0700 Subject: move sample examples out of config, show USAGE if no examples --- ariketa.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'ariketa.sh') 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 -- cgit v1.2.3