Skip to content

Instantly share code, notes, and snippets.

@YerkoPalma
Created May 24, 2017 02:38
Show Gist options
  • Save YerkoPalma/c9814be639efb165e8445667f36b901e to your computer and use it in GitHub Desktop.
Save YerkoPalma/c9814be639efb165e8445667f36b901e to your computer and use it in GitHub Desktop.
#!/bin/bash
bold=$(tput bold)
normal=$(tput sgr0)
# if there is not TEMPLATE folder
if [ -z "$TEMPLATES" ]; then
printf "%sbin/savior:%s TEMPLATES variable not set\n" "$bold" "$normal"
exit 1
fi
# if there is no template specified
if [ $# = "0" ]; then
printf "%susage:%s savior <template_name>\n" "$bold" "$normal"
exit 1
fi
# set the current template
template="$TEMPLATES/$1/main"
# if the main file of the template is not executable or doesn't exists
if [ ! -x "$template" ]; then
printf '%sbin/savior:%s template %s does not exist\n' "$bold" "$normal" "$1"
exit 1
fi
shift
"$template" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment