summaryrefslogtreecommitdiff
path: root/jh-help.sh
blob: 8986abc7ea29d19824551ffaffc0b9409e21c064 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash

stem=jh

master_help() {
	echo "Usage: $jh_short <command> [command-specific-arguments]"
	echo "Java helper for PKGBUILDs"
	echo ""
	jh-list-commands|sed 's/./  &/'
}

generic_help() {
	local cmd=$1
	cmd=${cmd##*/}
	cmd=${cmd#$stem-}

	file=`find ${PATH//:/ } -type f -name "$stem-$cmd.help.txt" 2>/dev/null`
	if [[ -r $file ]]; then
		sed "s|@cmd@|$jh_short|g" "$file"
	else
		echo "$jh_short: Cannot find help file for '$cmd'" >> /dev/stderr
		exit 1
	fi
}

case $# in
    0) master_help; exit 0;;
    1) generic_help "$1"; exit 0;;
    *) generic_help help; exit 1;;
esac