Skip to content

Commit cd4da41

Browse files
committed
Show usage in case command doesn't exist
1 parent b868549 commit cd4da41

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

bin/cppsm

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33
# shellcheck source=../commands/.settings
44
. "${BASH_SOURCE%/*/*}/commands/.settings"
55

6-
COMMAND="$1"
6+
COMMAND="$CPPSM/commands/$1"
77
shift
88

9-
"$CPPSM/commands/$COMMAND" "$@"
9+
if [ ! -x "$COMMAND" ]; then
10+
# shellcheck disable=SC2035
11+
COMMANDS="$(cd "$CPPSM/commands" && echo *)"
12+
COMMANDS="${COMMANDS// /|}"
13+
cat << EOF
14+
Usage: ${0##*/} [$COMMANDS]
15+
EOF
16+
exit 1
17+
fi
18+
19+
"$COMMAND" "$@"

0 commit comments

Comments
 (0)