Commit 88a9b63a authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Improved argument check messages

parent f473855a
Loading
Loading
Loading
Loading
+20 −15
Original line number Diff line number Diff line
@@ -80,7 +80,11 @@ cmd_init ()

_basic_check ()
{
	contains "$HOOKS" "$hook" || die "unknown hook '$hook'"
	if ! contains "$HOOKS" "$hook"; then
		echo -n "Usage: "
		parse_args $1 --help || true
		die "unknown hook '$hook'"
	fi
	[ -d "$GIT_DIR"/hooks/$hook.d ] || \
		die "the '$hook' hook directory does not appear to exist, you should \
		     run 'git-hooks init'"
@@ -95,7 +99,8 @@ _change_check ()

_installed_check ()
{
	[ -e "$GIT_DIR"/hooks/$hook.d/"$script" ] || \
	[ -e "$GIT_DIR"/hooks/$hook.d/"$script" ] && \
		! [ -d "$GIT_DIR"/hooks/$hook.d/"$script" ] || \
			die "there is no script '$script' in the '$hook' hook directory"
}

@@ -106,8 +111,8 @@ cmd_add ()
	add_option hook yes
	add_option script yes
	parse_args "$@" || return
	_basic_check
	_change_check
	_basic_check "$@"
	_change_check "$@"

	[ -e "$script" ] || die "unknown script '$script'"
	[ -e "$GIT_DIR"/hooks/$hook.d/"`basename "$script"`" ] && \
@@ -124,9 +129,9 @@ cmd_remove ()
	add_option hook yes
	add_option script yes
	parse_args "$@" || return
	_basic_check
	_change_check
	_installed_check
	_basic_check "$@"
	_change_check "$@"
	_installed_check "$@"

	rm "$GIT_DIR"/hooks/$hook.d/"$script"
}
@@ -138,9 +143,9 @@ cmd_enable ()
	add_option hook yes
	add_option script yes
	parse_args "$@" || return
	_basic_check
	_change_check
	_installed_check
	_basic_check "$@"
	_change_check "$@"
	_installed_check "$@"

	chmod +x "$GIT_DIR"/hooks/$hook.d/"$script"
}
@@ -152,9 +157,9 @@ cmd_disable ()
	add_option hook yes
	add_option script yes
	parse_args "$@" || return
	_basic_check
	_change_check
	_installed_check
	_basic_check "$@"
	_change_check "$@"
	_installed_check "$@"

	chmod -x "$GIT_DIR"/hooks/$hook.d/"$script"
}
@@ -165,7 +170,7 @@ cmd_installed ()
	local hook
	add_option hook yes
	parse_args "$@" || return
	_basic_check
	_basic_check "$@"

	cd "$GIT_DIR"/hooks/$hook.d
	find -type f -printf '%P\n'