summaryrefslogtreecommitdiff
path: root/git-shell-commands/help
diff options
context:
space:
mode:
Diffstat (limited to 'git-shell-commands/help')
-rwxr-xr-xgit-shell-commands/help29
1 files changed, 24 insertions, 5 deletions
diff --git a/git-shell-commands/help b/git-shell-commands/help
index f2970d5..0792cb5 100755
--- a/git-shell-commands/help
+++ b/git-shell-commands/help
@@ -1,12 +1,31 @@
-#!/bin/sh
-# * help
+#!/usr/bin/env bash
+# * help [COMMAND]
# Get enabled commands
-# ssh git@host help
+# Example: help
+# Example: help create-bare-repo
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 "$(dirname "$0")"/*; do
+for c in "${cmds[@]}"; do
sed -rn '2,/^[^#]/s/^# ?//p' "$c"
echo
-done
+done |
+if test -z "$TERM" || test "$TERM" = dumb; then
+ sed "s/Example: /&ssh $USER@$HOSTNAME /"
+else
+ cat
+fi