From 7097b57fc99a358bf81c41d61c0a4aacf6b58e61 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 12 Jul 2013 11:05:17 -0400 Subject: print_cmd_usage(): Implement and use. --- diff --git a/lib/cmd.sh b/lib/cmd.sh index cff225b..ff81c4a 100644 --- a/lib/cmd.sh +++ b/lib/cmd.sh @@ -71,6 +71,17 @@ print_cmd_summaries() done } +print_cmd_usage() +{ + local cmd usage + + cmd="${1}" + + usage="$(eval printf \'%s\' \"\$\{cmd_"${cmd}"_usage\}\")" + + printf 'Usage: %s %s %s\n' "${0}" "${cmd}" "${usage}" +} + is_cmd() { local cmd diff --git a/lib/cmd/help.sh b/lib/cmd/help.sh index 129cb14..39de93f 100644 --- a/lib/cmd/help.sh +++ b/lib/cmd/help.sh @@ -22,8 +22,12 @@ cmd_usage '[]' cmd_help_main() { + local cmd + if [ ${#} -eq 1 ]; then - if is_cmd "${1}"; then + cmd="${1}" + if is_cmd "${cmd}"; then + print_cmd_usage "${cmd}" return 0 fi fi -- cgit v0.9.1