Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the cmd-line args match cowsay's usage #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions pokemonsay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ usage() {
echo " Choose what pokemon will be used by its name."
echo " -f, --file COW_FILE"
echo " Specify which .cow file should be used."
echo " -w, --word-wrap COLUMN"
echo " -W, --word-wrap COLUMN"
echo " Specify roughly where messages should be wrapped."
echo " -n, --no-wrap"
echo " Do not wrap the messages."
echo " -l, --list"
echo " List all the pokémon available."
echo " -n, --no-name"
echo " -N, --no-name"
echo " Do not tell the pokémon name."
echo " -t, --think"
echo " Make the pokémon think the message, instead of saying it."
Expand Down Expand Up @@ -62,14 +64,18 @@ case $key in
COW_FILE="${1#*=}"
shift
;;
-w|--word-wrap)
-W|--word-wrap)
WORD_WRAP="$2"
shift; shift
;;
-w=*|--word-wrap=*)
-W=*|--word-wrap=*)
WORD_WRAP="${1#*=}"
shift
;;
-n|--no-wrap)
DISABLE_WRAP="YES"
shift
;;
-l|--list)
list_pokemon
;;
Expand Down Expand Up @@ -101,8 +107,11 @@ case $key in
esac
done

# Define where to wrap the message.
if [ -n "$WORD_WRAP" ]; then
# Disable wrapping if the option is set, otherwise
# define where to wrap the message.
if [ -n "{DISABLE_WRAP:-}" == "YES" ]; then
word_wrap="-n"
elif [ -n "$WORD_WRAP" ]; then
word_wrap="-W $WORD_WRAP"
fi

Expand Down