diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-05-12 19:23:16 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-05-12 19:23:16 -0400 |
commit | 272f57b2a4d9f2c8d5ac3c46962f25c55dfbb270 (patch) | |
tree | 90055d8d7e394ae5377200ee2ec00afa4b861f0b /jh-help.sh | |
parent | b2c326dc625c0ee7cdfb5763b036db6893db9efd (diff) |
simplify by moving usage() into jh-help, jh no longer needs to be included
Diffstat (limited to 'jh-help.sh')
-rw-r--r-- | jh-help.sh | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -1,8 +1,30 @@ #!/bin/bash -. jh + +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) usage ''; exit 0;; - 1) usage "$1"; exit 0;; - *) usage help; exit 1;; + 0) master_help; exit 0;; + 1) generic_help "$1"; exit 0;; + *) generic_help help; exit 1;; esac |