mirror of
https://github.com/kazhala/dotbare
synced 2024-11-06 09:20:25 +00:00
67 lines
1.3 KiB
Bash
Executable File
67 lines
1.3 KiB
Bash
Executable File
#!/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
|
|
|
|
function usage() {
|
|
echo "help"
|
|
}
|
|
|
|
# if no argument passed in, let git display help message
|
|
if [[ $# -eq 0 ]]; then
|
|
/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
|
|
;;
|
|
freset)
|
|
action_command='freset'
|
|
shift
|
|
;;
|
|
fcheckout)
|
|
action_command='fcheckout'
|
|
shift
|
|
;;
|
|
help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
-h)
|
|
usage
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
if [[ -z "${action_command}" ]]; then
|
|
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" "$@"
|
|
else
|
|
# run the scripts
|
|
"${mydir}/scripts/${action_command}" "$@"
|
|
fi
|