Commit 28e3ef43 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Added more help message detail

parent d59f0871
Loading
Loading
Loading
Loading
+28 −11
Original line number Diff line number Diff line
@@ -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 ()
{
@@ -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
}