Loading git-hooks +28 −11 Original line number Diff line number Diff line Loading @@ -29,15 +29,27 @@ GIT_DIR="${GIT_DIR:-`git rev-parse --git-dir`}" usage () { cat <<-USAGE Usage: $BIN init $BIN add [-p <priority>] <hook> <script> $BIN remove <hook> <script> $BIN help USAGE for func in `declare -F | cut -f3 -d\ | grep ^cmd_`; do commands=( "${commands[@]}" ${func#cmd_} ) done IFS=\| echo "Usage: $BIN ${commands[*]} [--help] ..." } full_usage () { usage echo "Sub-commands:" echo "-------------" for command in "${commands[@]}"; do echo echo -n "$command: " eval cmd_$command $command --summary || true eval cmd_$command $command --help || true echo "-------------" free_args done } add_arg () { Loading Loading @@ -151,22 +163,27 @@ free_args () cmd_init () { echo summary="set up git-hook directories in a repository" parse_args "$@" } cmd_add () { echo summary="add a script to a hook" parse_args "$@" || return } cmd_remove () { echo summary="remove a script from a hook" parse_args "$@" || return } cmd_help () { usage summary="show this help message" parse_args "$@" || return full_usage exit 0 } Loading Loading
git-hooks +28 −11 Original line number Diff line number Diff line Loading @@ -29,15 +29,27 @@ GIT_DIR="${GIT_DIR:-`git rev-parse --git-dir`}" usage () { cat <<-USAGE Usage: $BIN init $BIN add [-p <priority>] <hook> <script> $BIN remove <hook> <script> $BIN help USAGE for func in `declare -F | cut -f3 -d\ | grep ^cmd_`; do commands=( "${commands[@]}" ${func#cmd_} ) done IFS=\| echo "Usage: $BIN ${commands[*]} [--help] ..." } full_usage () { usage echo "Sub-commands:" echo "-------------" for command in "${commands[@]}"; do echo echo -n "$command: " eval cmd_$command $command --summary || true eval cmd_$command $command --help || true echo "-------------" free_args done } add_arg () { Loading Loading @@ -151,22 +163,27 @@ free_args () cmd_init () { echo summary="set up git-hook directories in a repository" parse_args "$@" } cmd_add () { echo summary="add a script to a hook" parse_args "$@" || return } cmd_remove () { echo summary="remove a script from a hook" parse_args "$@" || return } cmd_help () { usage summary="show this help message" parse_args "$@" || return full_usage exit 0 } Loading