quick addition of a listing argument

This commit is contained in:
Erkin Batu Altunbaş 2012-04-05 17:17:13 +02:00
parent a6ca6e858a
commit 6fab3575cd

13
ponysay
View file

@ -13,6 +13,15 @@ version() {
echo "ponysay v$version" echo "ponysay v$version"
} }
list() {
echo "ponyfiles located in $SYSTEMPONIES:"
ls -1 $SYSTEMPONIES | sed "s/.pony//"
if [[ -d $HOMEPONIES ]]; then
echo "ponyfiles located in $HOMEPONIES:"
ls -1 $HOMEPONIES | sed "s/.pony//"
fi
}
usage() { usage() {
version version
cat <<EOF cat <<EOF
@ -25,6 +34,7 @@ If [message] is not provided, reads the message from STDIN
Options: Options:
-v Show version and exit -v Show version and exit
-h Show this help and exit -h Show this help and exit
-l List ponyfiles.
-f[name] Select a pony (Either a filename or a pony name) -f[name] Select a pony (Either a filename or a pony name)
-W[column] The screen column where the message should be wrapped -W[column] The screen column where the message should be wrapped
EOF EOF
@ -37,12 +47,13 @@ say() {
exec "$cmd" -f "$pony" "${wrap:+-W$wrap}" exec "$cmd" -f "$pony" "${wrap:+-W$wrap}"
} }
while getopts f:W:hv OPT while getopts f:W:lhv OPT
do do
case ${OPT} in case ${OPT} in
v) version; exit ;; v) version; exit ;;
h) usage; exit ;; h) usage; exit ;;
f) pony="$OPTARG" ;; f) pony="$OPTARG" ;;
l) list; exit ;;
W) wrap="$OPTARG" ;; W) wrap="$OPTARG" ;;
\?) usage >&2; exit 1 ;; \?) usage >&2; exit 1 ;;
esac esac