From d757e49a4042b3659c906a2bb404abd6e9eb853f Mon Sep 17 00:00:00 2001 From: Parabola git Date: Fri, 8 Jul 2016 01:50:36 +0000 Subject: improve "help" text --- git-shell-commands/help | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'git-shell-commands/help') 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 -- cgit v1.2.3-54-g00ecf