~ecs/tm

d53ea09687550319c4652fd87f67c8157af21925 — Ember Sawady 3 years ago 357d4f2
List subcommands
1 files changed, 15 insertions(+), 6 deletions(-)

M tm
M tm => tm +15 -6
@@ 1,15 1,24 @@
#!/bin/sh -eu

cd "$(dirname -- "$0")"
export PATH="$PWD:$PATH"
cd - >/dev/null
usage() {
	echo "usage: tm command [subcommand...]"
	# TODO: list subcommands?
	echo "usage: tm <command> [<subcommand>...]"
	echo "valid values for <command>:"
	IFS=:
	for path in $PATH; do
		cd "$path" 2>/dev/null || continue
		IFS=
		for file in tm-*; do
			[ -x "$file" ] && printf "\t%s\n" "${file#tm-}"
		done
		IFS=:
		cd - >/dev/null
	done | sort | uniq
	exit 1
}

[ $# -eq 0 ] && usage
cd "$(dirname -- "$0")"
export PATH="$PWD:$PATH"
cd - >/dev/null
. "$(dirname -- "$0")/lib.sh"
cmd="$1"
shift