#!/usr/bin/env bash
# * help [COMMAND...]
#   Get enabled commands
#   Example: help
#   Example: help create-bare-repo change-owner

set -e

HOSTNAME=git.parabola.nu

if [[ "$*" = */* ]]; then
	printf 'Command names may not contain /\n'
	exit 1
fi

if test $# = 0; then
	cmds=("$(dirname "$0")"/*)
else
	cmds=("${@/#/"$(dirname "$0")/"}")
fi

# Gets the initial comment after the shebeng from every git-shell-command
for c in "${cmds[@]}"; do
	sed -rn '2,/^[^#]/s/^# ?//p' "$c"
	echo
done |
if test -z "$TERM" || test "$TERM" = dumb; then
	sed "s/Example: /&ssh $USER@$HOSTNAME /"
else
	cat
fi