#!/bin/bash ### # Parses arguments and commands from shell ### GIT_DIR="./" #Recursive argument parser while true; do case ${1} in --help) shift HELP="${1}" [[ -z "${HELP}" ]] && HELP=general eval help_${HELP} exit ;; --info) help_info exit ;; --git-dir=*) if [ -z "${1#*=}" ]; then help else GIT_DIR="${1#*=}" fi ;; *) break ;; esac shift done case "${1}" in exclude) shift cmd_exclude "${GIT_DIR}" ${@} EXIT=$? [[ ${EXIT} -eq 3 ]] && echo "Database file non-existent" [[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository" ;; include) shift cmd_include "${GIT_DIR}" ${@} EXIT=$? [[ ${EXIT} -eq 3 ]] && echo "Database file non-existent" [[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository" ;; deploy) shift cmd_deploy "${GIT_DIR}" ${@} EXIT=$? [[ ${EXIT} -eq 0 ]] && echo "Deployment completed successfully" [[ ${EXIT} -eq 1 ]] && echo "Deployment completed with errors" [[ ${EXIT} -eq 3 ]] && echo "Database file non-existent" [[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository" ;; update) shift cmd_update "${GIT_DIR}" ${@} EXIT=$? [[ ${EXIT} -eq 0 ]] && echo "Update completed successfully" [[ ${EXIT} -eq 1 ]] && echo "Update completed with errors" [[ ${EXIT} -eq 3 ]] && echo "Database file non-existent" [[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository" ;; du) shift cmd_du "${GIT_DIR}" "${@}" EXIT=$? [[ ${EXIT} -eq 3 ]] && echo "Database file non-existent" [[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository" ;; fsck) shift cmd_fsck "${GIT_DIR}" "${@}" EXIT=$? [[ ${EXIT} -eq 3 ]] && echo "Database file non-existent" [[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository" ;; esac