Skip to content

Commit

Permalink
Merge pull request #10 from JackDanger/danger/usage-list
Browse files Browse the repository at this point in the history
Print list of supported emojis
  • Loading branch information
mrowa44 authored Jun 27, 2016
2 parents 560758e + cd277e3 commit 4c54448
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions emojify
Original file line number Diff line number Diff line change
Expand Up @@ -948,23 +948,37 @@ help () {
cat <<EOF
emojify - emoji on the command line 😱
USAGE: emojify [-h|--help] TEXT
USAGE: emojify [-h|--help] [-l|--list] TEXT
EOF
}

# Accept input from $* or from the pipeline
if test "$*" != ''; then
if [ "$1" == '-h' ] || [ "$1" == '--help' ]; then
help
exit 0
else
IFS=' '; read -a words_arr <<< $*
for word in "${words_arr[@]}"; do
data+=$(emojify $word)
data+=' '
if [[ 'list' == $1 ]]; then
echo ''
echo 'Supported emojis:'
for key in ${!keys[@]}; do
echo " " ${values[$key]} " " ${keys[$key]}
done
echo $data
fi
exit 0
}

# If arguments are provided on the command line then check for supported help
# options or process the arguments as emoji names.
if [[ -n $1 ]]; then
case $1 in
'-h' | '--help' )
help
;;

'-l' | '--list' )
help list
;;

* )
IFS=' '; read -a words_arr <<< $*
for word in "${words_arr[@]}"; do
echo -n "$(emojify $word) "
done
;;
esac
else
while IFS=''; read -r line || [ -n "$line" ]; do
echo $(emojify $line)
Expand Down

0 comments on commit 4c54448

Please sign in to comment.