You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dotbare/dotbare

75 lines
1.4 KiB
Plaintext

4 years ago
#!/bin/bash
#
# Main entry script for dotbare, used to route command to appropriate scripts
#
# @params
# Globals
# ${mydir}: string, directory of the executing script, used for sourcing helpers
# ${action_command}: string, determine which script to call
# Arguments
# action_command: sub commands dotbare should run
# General git command: log, status etc
# dotbare specific commands: fadd | frm | fpop | freset | fcheckout | help
# option flags:
# check sub commands for available option flags
mydir="${0%/*}"
source "${mydir}"/helper/set_variable.sh
4 years ago
function usage() {
echo "help"
}
# if no argument passed in, let git display help message
if [[ $# -eq 0 ]]; then
4 years ago
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}"
exit 0
fi
action_command=''
case "$1" in
fadd)
action_command='fadd'
shift
;;
frm)
action_command='frm'
shift
;;
fpop)
action_command='fpop'
shift
;;
4 years ago
freset)
action_command='freset'
shift
;;
4 years ago
fcheckout)
action_command='fcheckout'
shift
;;
4 years ago
fstat)
action_command='fstat'
shift
;;
4 years ago
fedit)
action_command='fedit'
shift
;;
help)
usage
exit 0
;;
-h)
usage
exit 0
;;
esac
if [[ -z "${action_command}" ]]; then
4 years ago
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" "$@"
else
# run the scripts
"${mydir}/scripts/${action_command}" "$@"
fi