summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-09-28 10:38:33 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-09-28 10:38:33 -0400
commit8946dd3f509a242b8ec06dbaf5522113f56671fb (patch)
tree734c0f9324e57a6662118aef4f2e9476c6922485
parent5a5c2aede987abb16a123b71de4d34c3cec2c0a3 (diff)
Add a list-commands command
-rw-r--r--Makefile2
-rw-r--r--jh-list-commands.help.txt2
-rw-r--r--jh-list-commands.sh13
3 files changed, 16 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 0303236..4794be4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-subcommands = help mvn-basename mvn-install mvn-localrepo
+subcommands = help list-commands mvn-basename mvn-install mvn-localrepo
dirs = $(DESTDIR)/usr/share/jh $(DESTDIR)/usr/bin
####
diff --git a/jh-list-commands.help.txt b/jh-list-commands.help.txt
new file mode 100644
index 0000000..504d6c6
--- /dev/null
+++ b/jh-list-commands.help.txt
@@ -0,0 +1,2 @@
+Usage @cmd@ list-commands
+Lists available subcommands and a short description.
diff --git a/jh-list-commands.sh b/jh-list-commands.sh
new file mode 100644
index 0000000..290b4e1
--- /dev/null
+++ b/jh-list-commands.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+. /usr/bin/jh
+
+if [[ $# > 0 ]]; then
+ usage
+ exit 1
+fi
+
+for cmd_help in "$JH_PATH"/*.help.txt; do
+ cmd=`echo "$cmd_help"|sed -r 's|.*/jh-(.*)\.help\.txt$|\1|'`
+ help=`sed -n 2p "$cmd_help"`
+ printf "%-20s %s\n" "$cmd" "$help"
+done